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



Ask a Question

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. I need some help. I am a programmer - but quite n
View Tutorial          By: Ron at 2013-06-21 00:58:27

2. Hi Sir...
sir i am working on Speech to Tex

View Tutorial          By: Sadaquat at 2012-08-19 07:51:28

3. hi,

i am trying to run this SMS jav

View Tutorial          By: Raghavendra at 2010-12-29 08:27:02

4. As a beggnar, i find it varry varry usefuull.... P
View Tutorial          By: Rameeza at 2011-05-17 03:14:50

5. Hello,

A volatile variable does not

View Tutorial          By: aayush at 2009-11-16 07:38:23

6. excellent
View Tutorial          By: santosh at 2012-08-28 06:12:44

7. Hats off man !!! Very Simple & Straightforward
View Tutorial          By: Nitesh at 2013-01-06 00:50:53

8. This program is faulty .

Check for

View Tutorial          By: Shrikant Kale at 2014-09-09 07:31:04

9. You have stretch it more then enough even then the
View Tutorial          By: Chirag at 2012-12-04 16:15:13

10. Nice post. Can you tell me how can i add shape in
View Tutorial          By: Sonia at 2012-06-08 04:57:18