Saturday, 1 December 2012

Insert Data into Database using Swings,Applets part-3

// siddhu vydyabhushana // 11 comments
this part-3 is followed by before 2 parts links are

PART-1

http://javatyro.blogspot.in/2012/12/insert-data-into-database-using.html

PART-2

http://javatyro.blogspot.in/2012/12/insert-data-into-database-using_1.html




DOWNLOAD FULL CODING
                                   download

DATABASE

DB




DATABASE CONNECTION WITHOUT DSN

try
{
String database="sample.mdb";//Here database exists in the current directory

//this connection is without DSN
String url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + database + ";DriverID=22;READONLY=true";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url);
PreparedStatement st=con.prepareStatement("insert into reg(username,password,gender,email) values(?,?,?,?)");
st.setString(1,name);
st.setString(2,pass);
st.setString(3,g);
st.setString(4,email);
st.executeUpdate();
JOptionPane.showMessageDialog(null,"Data is successfully inserted into database.");
}
catch( Exception ex){}
}

11 comments: