0

I'm trying to execute a query in java but it throws an exception

try {
 conn = DriverManager.getConnection(DatabaseURL + DatabaseName, UserName, Password);
 System.out.println("1");
 Message = "data retrieved successfully ...";
 //Statement st = this.conn.createStatement();// Membuat Statement
 System.out.println("2");
 pr = conn.prepareStatement("SELECT `الكلمة` FROM `name1` WHERE `الموضوع` LIKE 'أداة الطحن' ;");
 System.out.println("3");
 res = pr.executeQuery();
 System.out.println("4");
} catch (Exception e) {
 System.out.println("5");
 Message = "connection failed \r\n " + e.getMessage();
 return null;
}

it prints 1 2 3 5 so there is a problem in executing the query so that it does not print 4 I tried to run it on sql and it works what's the problem here???

10
  • 1
    What is the error code and dbms? Commented Aug 5, 2013 at 10:14
  • 2
    Which Exception is thrown? Commented Aug 5, 2013 at 10:15
  • 3
    Do you really have a column called الموضوع? Commented Aug 5, 2013 at 10:16
  • 2
    can you replace System.out.println("5"); by e.printStackTrace(); and post the stacktrace please? Commented Aug 5, 2013 at 10:20
  • com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column '??????' in 'field list' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) Commented Aug 5, 2013 at 10:33

1 Answer 1

4

You have a semicolon at last in the query.Maybe this is the problem.

answered Aug 5, 2013 at 10:18
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.