mysql - Java SELECT query You have an error in your SQL syntax -
i'm getting following error
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'date = '2015-04-26' order tracenum' @ line 1
this query
"select name, sporecount.* sporesfungi inner join sporecount on sporesfungi.idspore = sporecount.idspore date = ? order tracenum";
if remove clause query works fine.
this full code
public void exporttoexcel(string date) throws ioexception, biffexception, writeexception, sqlexception, parseexception{ db_connect connection = new db_connect(); conn = connection.connect(); string originalfile = "c:\\users\\geni\\desktop\\book1-template-new.xls"; date = date.replace("/", "-"); simpledateformat mydate = new simpledateformat("yyyy-mm-dd"); try{ workbook original = workbook.getworkbook(new file(originalfile)); writableworkbook copy = workbook.createworkbook(new file(date+".xls"), original); java.util.date format = mydate.parse(date); java.sql.date newdate = new java.sql.date(format.gettime()); string sql = "select name, sporecount.* sporesfungi " + "inner join sporecount on sporesfungi.idspore = sporecount.idspore" + "where date = ? order tracenum"; preparedstatement statement = conn.preparestatement(sql); statement.setdate(1, newdate); rs = statement.executequery(); /*stmt = conn.createstatement(); rs = stmt.executequery(sql);*/ writablesheet sheet = copy.getsheet(0); writablecell cell; string spore; while(rs.next()){ for(int = 2; < 64 ;i++){ cell = sheet.getwritablecell(1,i); spore = cell.getcontents(); if(rs.getstring("name").equals(spore)){ number l1 = new number(14-rs.getint("tracenum"),i,rs.getint("amount")) ; sheet.addcell(l1); } } } copy.write(); copy.close(); original.close(); } catch (biffexception | ioexception e) { } }
there no space before where.
Comments
Post a Comment