Comment on Tutorial - How to Send SMS using Java Program (full code sample included) By Emiley J.



Comment Added by : nishi

Comment Added at : 2011-12-09 02:00:20

Comment on Tutorial : How to Send SMS using Java Program (full code sample included) By Emiley J.
package practice_bo;

import practice_bean.practice_bean;
import practice_dao.practice_dao;

public class practice_bo {




public void asign(practice_bean practice_Beanobj) {
// TODO Auto-generated method stub
practice_dao practice_daoobj = new practice_dao();

practice_daoobj.newasign(practice_Beanobj);

}

public void asignn(practice_bean practiceobjj) {
// TODO Auto-generated method stub
practice_dao practice_daoobj=new practice_dao();
practice_daoobj.asignn1(practiceobjj);

}


}



package practice_dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import practice_bean.practice_bean;
import practice_utility.practice_db;

public class practice_dao {



public int newasign(practice_bean practiceBeanobj) {
// TODO Auto-generated method stub

practice_db dbconnobj=new practice_db();
Connection conn=dbconnobj.getConnection();
try
{
PreparedStatement ps = conn.prepareStatement("insert into practice values(?,?)");
ps.setString(1,practiceBeanobj.getUsername());
ps.setString(2,practiceBeanobj.getPassword());
ps.executeUpdate();
}
catch

(Exception e){
e.printStackTrace();
}

finally
{
dbconnobj.closeConnection(conn);
}
return 0;

}

public void asignn1(practice_bean practiceobjj) {

// TODO Auto-generated method stub
practice_db practice_dbobjj=new practice_db();
Connection connn=practice_dbobjj.getConnection();
try
{

PreparedStatement ps=connn.prepareStatement("delete from practice where Username=?");
ps.setString(1,practiceobjj.getUsername());
ps.executeUpdate();
}
catch

(Exception e){
e.printStackTrace();
}

finally
{
practice_dbobjj.closeConnection(connn);
}

return;
}
}


package practice_servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import practice_bean.practice_bean;
import practice_bo.practice_bo;

/**
* Servlet implementation class practice_servlet
*/
public class practice_servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private practice_servlet set;

/**
* @see HttpServlet#HttpServlet()
*/
public practice_servlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
practice_bean practice_beanobj = new practice_bean();
practice_bo practice_boobj = new practice_bo();
String username = request.getParameter("txt_username");
String password = request.getParameter("txt_password");

practice_beanobj.setUsername(username);
practice_beanobj.setPassword(password);

practice_boobj.asign(practice_beanobj);

}


}
package practice_utility;
import java.sql.Connection;
import java.sql.DriverManager;
public class practice_db {

/**
* @author-indhu
* @return
*/


public Connection getConnection(){
Connection connection= null;
try {

// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);

// Create a connection to the database
String serverName = "172.24.137.30";
String portNumber = "1521";
String sid = "ora10g";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "e526993";
String password = "fuvwKLYnr";
connection = DriverManager.getConnection(url, username, password);
}
/* System.out.println(connection);

Statement st = connection.createStatement();

ResultSet rs = st.executeQuery("select * from teststudent");

while(rs.next()){
System.out.println("name ::"+ rs.getString(2));
}*/
catch (Exception e){
System.out.println("exception "+e);
}
return connection;
}
public void closeconnection(Connection conn, Object Connection){
if (conn!=null);
try
{
conn.close();
}

catch(Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}

return;
}
public void closeConnection(Connection connn){
if (connn!=null);
try
{
connn.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>practice</title>
<script type="text/javascript">
function main()
{
if (!validusername())
return false;
if (!validpassword())
return false;
}
function validusername()
{

var x=document.forms["practice"]["txt_username"].value;
var y=/^[a-zA-Z]+$/
if (x.match(y))
return true;
else
{
alert ("enter valid username");
return false;
}
}
function validpassword()
{
var M=document.forms["practice"]["txt_password"].value;
var N=/^[a-zA-Z]+$/
if(M.match(N))
return true;
else
{
alert ("enter valid password");
return false;
}

}


</script>
</HEAD>


<body>

<p><form name="practice" action="/practice/practice_servlet" onclick= "return main()" method="post">
<pre>
<p>
username: <input type="text" name="txt_username"><br>
Password: <input type="password" name="txt_password" maxlength=6><br>

<input type="submit" value="submit">



</pre>

</p>
</form>


</body>
</html>


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. very nice keep sharing thanks a lot
View Tutorial          By: Adeel at 2014-09-24 09:50:00

2. hi What is the meaning of this line ,
you c

View Tutorial          By: Anil Chalhotra at 2013-02-16 08:04:03

3. Thanks Man!! Been searching for a simple one like
View Tutorial          By: Kid at 2012-10-12 14:15:43

4. please show many codes in c++....thankZz
View Tutorial          By: Maybelline Hope Bongolan at 2008-08-20 17:50:51

5. what about memory in case of struts 2 at a time nu
View Tutorial          By: lakku at 2010-08-13 06:24:02

6. I have one doubt regarding this code,
if th

View Tutorial          By: Yellappa at 2010-06-11 05:49:15

7. Hello
thanks for nice tutorial. I have one

View Tutorial          By: Chanchal Prajapat at 2015-02-09 06:10:42

8. string strInsert = "Insert into [Sheet1$](F1,
View Tutorial          By: Sagar at 2011-05-12 06:47:13

9. Hi, my name is Jaime,
I wan't to do a jsp w

View Tutorial          By: Jaime at 2011-10-24 12:47:50

10. This is just Great, didn't find anything like this
View Tutorial          By: Vikrant Verma at 2012-10-07 04:54:42