Vote count:
0
I have a SQL Call in my MySQL workbench to test so that I could ensure that the syntax was correct, I double checked and it works, however when I use the same syntax in my java class to pass it to the database and get information I get a SQLException like this
Error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version for the
right syntax to use near 'JOIN customers on customers.ANum = leads.ANum JOIN automobiles
on automobiles.AN' at line 1
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version for the right
syntax to use near 'JOIN customers on customers.ANum = leads.ANum JOIN automobiles on
automobiles.AN' at line 1
Here is me Syntax in MySQL:
SELECT leads.Anum, leads.recDate, leads.status, leads.salesman, leads.apptDt,
leads.appTime, leads.notes,customers.fName, customers.mName, customers.lName,
customers.phone, customers.cell, customers.work, customers.bestTime, customers.email,
customers.addr1, customers.addr2, customers.city, customers.state, customers.zip,
customers.rentOwn, customers.pmtMo, customers.livedMo, customers.livedYr,
customers.ssn, customers.birthday, customers.employer, customers.incomeMo,
customers.empMo, customers.empYr, customers.creditApp, automobiles.newUsed,
automobiles.extColorWant, automobiles.intColorWant, automobiles.desiredInfo,
automobiles.extColor, automobiles.intColot, automobiles.yearHave, automobiles.make,
automobiles.model, automobiles.mileage, automobiles.goodPoor FROM leads JOIN customers
on customers.ANum = leads.ANum JOIN automobiles on automobiles.ANum = customers.ANum
where leads.dealer = 'SKA' and leads.recDate between '2013-01-01' and '2014-12-31'
order by leads.recDate DESC;
Syntax for My Java SQL Call:
String sql = "SELECT leads.Anum, leads.recDate, leads.status, leads.salesman, leads.apptDt, leads.appTime, leads.notes,"
+ "customers.fName, customers.mName, customers.lName, customers.phone, customers.cell, customers.work,"
+ "customers.bestTime, customers.email, customers.addr1, customers.addr2, customers.city, customers.state,"
+ "customers.zip, customers.rentOwn, customers.pmtMo, customers.livedMo, customers.livedYr, customers.ssn,"
+ "customers.birthday, customers.employer, customers.incomeMo, customers.empMo, customers.empYr, customers.creditApp,"
+ "automobiles.newUsed, automobiles.extColorWant, automobiles.intColorWant, automobiles.desiredInfo, automobiles.extColor, automobiles.intColot,"
+ "automobiles.yearHave, automobiles.make, automobiles.model, automobiles.mileage, automobiles.goodPoor"
+ "FROM leads JOIN customers on customers.ANum = leads.ANum JOIN automobiles on automobiles.ANum = customers.ANum Where leads.dealer = "
+ "? and leads.recDate between ? and ? order by leads.recDate DESC";
As I said Before The SQL Call in MySQL works just fine, returns exactly what I want it to return, But I get the SQL Exception in my java web application, Any Ideas what could be going wrong here. My first impression is that for whatever reason the Java sql library doesn't like the syntax, and if that is the case where would I find documentation on how to resolve the issue.
asked 1 min ago
Why is my sql call working in MySQL but not in my Java class
Aucun commentaire:
Enregistrer un commentaire