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



Related Tutorials

Java program to get location meta data from an image

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

Archived Comments

1. In your example http://twitter.com/statuses/updat
View Tutorial          By: thomas wilkinson at 2012-11-02 01:03:45

2. Awesome One....... Thanx...... m new to java...and
View Tutorial          By: jayanta at 2010-02-05 04:35:34

3. I want more example of bufferedReader.
View Tutorial          By: Romulado Bacor at 2011-11-25 01:18:57

4. its gud 2 learn java sim prog
View Tutorial          By: Rakesh at 2009-10-04 03:47:01

5. Hi, thanks for your code, I have modified a little
View Tutorial          By: Armando at 2010-08-10 09:34:35

6. how to calculate total value more item
View Tutorial          By: balaji at 2011-01-06 23:52:50

7. Sir,
i am implementing the above code in w

View Tutorial          By: Girish padki at 2010-01-15 21:50:50

8. i build j2me application for reading text file....
View Tutorial          By: ganesh at 2012-10-17 10:34:00

9. I was trying to copy your coding and execute it, b
View Tutorial          By: Guest at 2012-01-02 04:08:21

10. i want to say only one thing

great

View Tutorial          By: ashish at 2009-06-09 21:36:45