Java JDBC
some important statements in java jdbc:-
1) create table:- To create a table in JDBC we have to write the code in java
PreparedStatement ps=con.prepareStatement("create table srvan(id int, name varchar(400), last varchar(400), age int)");
ps.executeUpdate();
and after that we can insert data into table by using below code
2) Insert records:-
PreparedStatement ps1=con.prepareStatement("insert into sra100 values(?,?,?,?)");
ps1.setInt(1,3);
ps1.setString(2, "y");
ps1.setString(3, "sravan");
ps1.setInt(4, 9491);
int i=ps1.executeUpdate();
System.out.println(i+"records inserted");
some important statements in java jdbc:-
1) create table:- To create a table in JDBC we have to write the code in java
PreparedStatement ps=con.prepareStatement("create table srvan(id int, name varchar(400), last varchar(400), age int)");
ps.executeUpdate();
and after that we can insert data into table by using below code
2) Insert records:-
PreparedStatement ps1=con.prepareStatement("insert into sra100 values(?,?,?,?)");
ps1.setInt(1,3);
ps1.setString(2, "y");
ps1.setString(3, "sravan");
ps1.setInt(4, 9491);
int i=ps1.executeUpdate();
System.out.println(i+"records inserted");
0 comments:
Post a Comment