我想將數據插入,我using.I獲得MySQL數據庫這ERROR。這是我的代碼:MySQLSyntaxError插入MySQL數據庫
public boolean insertValues(String gisuniqkey,String objtype,String objkey,String lat,String lng)
{
int rc=-1;
try {
if(conn==null)
{
System.out.println("The connection was not initialized.");
return false;
}
Statement st=(Statement) conn.createStatement();
//lots of String concatenation,very expensive...BAD...use StringBuilder instead
String sql="Insert into ZMAPERP_GIS_DB (GISUNIQKEY,OBJTYPE,OBJKEY,LATITUDE,LONGITUDE) values("+gisuniqkey+","+objtype+","+objkey+","+lat+","+lng+");";
System.out.println(sql);
rc=st.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rc>0?true:false;
}
你缺少引號 – Strawberry
@Strawberry引號,但在那裏,這將是這串 – vamsiampolu
的正確版本,我會建議更改爲一個PreparedStatement而不是建立您的查詢字符串。 –