CREATE TEMPORARY TABLE testraghu(name VARCHAR(50) , phone VARCHAR(50))
Let us see one example for using this
public class TempTableExample {
public static void createTempTable(){
Connection con = null;
Statement stat = null;
Statement stat1 = null;
Statement stat2 = null;
ResultSet rs = null;
long now = 0;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "username", "password");
now = System.currentTimeMillis();
stat = con.createStatement();
int b;
stat.executeUpdate("CREATE TEMPORARY TABLE testraghu(name VARCHAR(50) , phone VARCHAR(50))");
stat1 = con.createStatement();
System.out.println("table created ");
stat1 = con.createStatement();
b=stat1.executeUpdate("insert into testraghu(name,phone)values('Raghuram',9840622121)");
if(b!=0){
System.out.println("inserted");
}
else{
System.out.println("not inserted");
}
stat2=con.createStatement();
rs=stat.executeQuery("select * from testraghu");
while(rs.next()){
System.out.println("name -- "+rs.getString("name"));
System.out.println("phone -- "+rs.getString("phone"));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String a[]) {
createTempTable();
}
}
I don't even know how I stopped up right here, but I thought this publish was great. I do not recognize who you're hοωеver
ReplyDeletecertainly yоu are goіng to a well-known blogger іn
the event yοu аrе not alreaԁу.
Ϲhеers!
my web ρage Mid Stakes Offer