Hi,
I am newbie to java stored procedure and db2. In my java stored procedure I am trying trying to drop a table and then create it. But it is not working. Any suggestions please??
java stored procedure code snippet
Code:
String localquery=null;
//Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Connection con1 =
DriverManager.getConnection("jdbc:default:connection");
PreparedStatement stmt = null;
//ResultSet rs = null;
try{
localquery= "drop table features";
stmt = con1.prepareStatement(localquery);
stmt.execute(localquery);
//con.commit();
System.out.println("Features Table deleted");
}
catch(SQLException tabledoesnotExist)
{
System.out.println("Features Table does not exist");
}
/*TABLE DELETED*/
/*CREATE TABLE FEATURES*/
try{
localquery="CREATE TABLE FEATURES(ColumnName Varchar(50), Keyword Varchar(50),Weight float)";
stmt = con1.prepareStatement(localquery);
stmt.execute(localquery);
//con.commit();
System.out.println("Features Table created");
}
catch(SQLException tabledoesnotExist)
{
System.out.println("Problem in creating Features Table");
}
/*TABLE CREATED*/
regards,
govind