I am new to java programming and still learning. I am trying to make a table in my database (in xammp) using sql code in Java.
I found no any error but the code just failed to execute.. I've tried fixed it many times and still have no any progress..
Maybe somebody know how to fix my program, please tell me.. That would be great.
I use NetBeans btw..
This is my source code :
private void saveActionPerformed(java.awt.event.ActionEvent evt) {
String name=category_name_tf.getText();
try {
Statement statement=(Statement) konek.GetConnection().createStatement();
statement.execute("CREATE TABLE '"+name+"'('"+jakarta+"','"+bogor+ "','"
+depok+ "','"+tangerang + "','"+bekasi+"');");//Is this codes right?
statement.close();
JOptionPane.showMessageDialog(null,"New Category Added");
category_name_tf.setText("");
}catch (Exception t){
JOptionPane.showMessageDialog(null,"Add Category Failed");
category_name_tf.requestFocus();
}
}
;at the end. also your input of the textfields need to contain the column name and the type in this formatname type