java - Uploading String to mySQL | syntax error -




i trying connect mysql database using java. seem able connect unable use stmt.executeupdate upload database. token trying upload string in console:

1b7a19bb5d924bc5b13d53c7b2a47394 connected com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near '1b7a19bb5d924bc5b13d53c7b2a47394' @ line 1

this code have in main class:

    string token = tokengenerator.generateqr(url, location);     tokens.add(token);     system.out.println(token);      try {       conn = drivermanager.getconnection(conn_string,username,password);     system.out.println("connected");     statement stmt = (statement) conn.createstatement();     stmt.executeupdate(token);     system.out.println("uploaded");     }catch (sqlexception e){     system.err.println(e);     } 

and how create token

public static string generateqr(string url, string location) throws exception {     string uuid = uuid.randomuuid().tostring();     uuid = uuid.replaceall("-", "");              string scan= url + uuid;            bytearrayoutputstream out = qrcode.from(scan).to(imagetype.png).stream();     file f = new file (location);     fileoutputstream fos = new fileoutputstream(f);     fos.write(out.tobytearray());     fos.flush();          return uuid;         } 

i unsure why not work , upload string database. thank in advance.

your generateqr function returns uuid not sql statement. returned value goest token variable later trying executed.





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

Asterisk AGI Python Script to Dialplan does not work -