السلام عليكم
اثناء محاولتي تطبيق مثال بسيط لقواعد البيانات باستخدام MYSQL حيث قمت ببناء جدولين بشكل يدوي ثم اردت تعبئة محتوى احدى الجداول عن طريق الكود برمجيا لكنه يعطيني خطأ لم اعرف كيف اتغلب عليه
ثم اقوم باستخدام الكود التالي :
import java.sql.*;
/**
*
* @author Mirage
*/
public class InsertBooks {
public static void main(String args[]) {
String url = "jdbc:mysql://localhost:3306/booksstore";
String username = "root";
String password = "root";
Connection con;
Statement stmt;
String query = "select BOOKNAME, PRICE from BOOKS";
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url, username, password);
stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO BOOKS " +
"VALUES (‘Java Programming’, 100, 450, 0, 0)");
stmt.executeUpdate("INSERT INTO BOOKS " +
"VALUES ('Windows XP', 100, 350, 0, 0)");
stmt.executeUpdate("INSERT INTO BOOKS " +
"VALUES ('Programming Concepts', 200, 650, 0, 0)");
stmt.executeUpdate("INSERT INTO BOOKS " +
"VALUES (‘Visual Basic 2008’, 300, 1000, 0, 0)");
stmt.executeUpdate("INSERT INTO BOOKS " +
"VALUES ('Internet', 150, 520, 0, 0)");
ResultSet rs = stmt.executeQuery(query);
System.out.println("Books and Prices:");
while (rs.next()) {
String s = rs.getString("BOOKNAME");
float f = rs.getFloat("PRICE");
System.out.println(s + " " + f);
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " +
ex.getMessage());
}
}
}لكنني وبشكل غير مفهوم احصل على الخطا التالي
SQLException: 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 '?Java Programming?, 100, 450, 0, 0)' at line 1
وسؤالي هو أين يكمن الخطأ وما سببه وكيف اصلاحه
مع العلم انه كل الاعدادات صحيحة والاتصال مع قاعدة البيانات صحيح
فارجو المساعدة وشكرا