我想將兩個值保存爲一個數據庫,我該怎麼做?在數據庫中將兩個值保存爲一個數據庫(SQL)
這裏是我的代碼:
try{
String v = "Voila";
String c = "Magic";
String url = "jdbc:mysql://localhost:3306/lemon";
Connection conn = DriverManager.getConnection(url,"r","s");
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO rtype set RType = '" + v + "'"); // how can I add 'c' in the same column?
conn.close();
}
catch (Exception e) {
System.err.println("Got an exception! ");
JOptionPane.showMessageDialog(null,"Please enter some values");
System.err.println(e.getMessage());
}
正如你所看到的,我有兩個字符串,我應該作爲一個然後保存在數據庫結合起來。
如果成功,該列應該有「Voila Magic」。