MySQL query not working in Java -


string sqlinsertbeacon = "insert `beacon` (zone_id, location) value ('(select id zone geographicalid = '" + geometry3 + "')', point(" + x_coordinate + "," + y_coordinate + "))"; system.out.println("the sql query is: " + sqlinsertbeacon);  // echo debugging int countinserted3 = stmt.executeupdate(sqlinsertbeacon); system.out.println(countinserted3 + " records inserted.\n"); 

when run above code, build successful program stops when reaches execute line. entering using sql query insert data mysql database. not sure error in query? can suggest alternative way or find mistake?

the output of program this, can see program, stops running after second line:

the sql query is: insert table (zone_id, location) values ((select id zone geographicalid = '6311599'), point(-121.9453802,37.3256131) ) ; build successful (total time: 6 seconds)

for additional information incase helps:

the stmt, created this:

 try (             // step 1: allocate database 'connection' object             connection conn = drivermanager.getconnection(                     "jdbc:mysql://localhost:3306/adhwere2?usessl=false", "root", "your_new_password"); // mysql              // step 2: allocate 'statement' object in connection             statement stmt = conn.createstatement();) { 

and catch exception :

} catch (sqlexception ex) {      } 

try this:

string sqlinsertbeacon = "insert `beacon` (zone_id, location)" +   " values ( (select id zone geographicalid = '" + geometry3 + "'), point(" +   x_coordinate + "," + y_coordinate + "))"; 

just removed apostrophes aroung inner select , replaced value values...


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -