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. ..how if the input is THE DOG BARKS then the outpu
View Tutorial          By: dharel at 2011-01-28 02:53:19

2. good. keep it up !
View Tutorial          By: hashu at 2011-06-21 01:49:59

3. pls sed total informatio about c++
View Tutorial          By: anu at 2009-07-22 11:13:07

4. as we write:
ob1.t.join();
Does t

View Tutorial          By: abc123 at 2011-04-03 13:33:33

5. Thank you, Every thing is working fine...!!

View Tutorial          By: Purushothaman at 2009-04-10 07:18:38

6. Thanks a lot......Plz help me to execute these fil
View Tutorial          By: Sanjana at 2013-01-26 10:15:12

7. hola

no funciona este
Stri

View Tutorial          By: ahmed at 2012-05-11 14:18:46

8. very very thankssssssssssssssss
View Tutorial          By: gowtham at 2010-07-31 22:58:36

9. Thanks!! This example was very helpful for me...
View Tutorial          By: Jonathas at 2010-03-11 07:47:51

10. it works! thanks! :D
however I would like t

View Tutorial          By: john at 2012-11-15 10:50:33