Hi everyone
I am new to
jdbc programming. I am trying to design a jdbc application through wich user will be able to pass table name and table structure during run time. My program would ask the user to pass table name and table fields through the console then it would create the specified table at the target database. I have tried the PreparedStatement interface but could not actually get to the method that would serve the purpose.
I have tried this code :
public void tableCreation()
{
BufferedReader br = new BufferedReader(new(InputStreamReader(System.in)));
System.out.println("Enter Table's Name:");
String tablename = br.readLine();
System.out.println("Enter filed name :");
String field1 = br.readLine();
System.out.println("Enter Filed Size");
int i = Integer.parseInt(br.readLine());
// and so on for the remaining fields.
//Can i use PreparedStatement object for that?
// How would my query to the database look like?
PreparedStatement pst = con.createStatement();
pst.execute(query);
}
Would highly appreciate your help.
Omar Salem