Hey guys
Am new to JDBC and am having some problems inserting into a table using variables. I am inserting into a table Players(PlayerID, firstname, surname, attempts). Player ID is autoincrement.
Here is the code:
Can anyone see where i am going wrong? Apparently i have an error in my sql syntax.HTML Code:try { Class.forName(driver).newInstance(); conn = DriverManager.getConnection(url+dbName,userName,password); System.out.println("Connected to the database"); String insertPlayer = ("INSERT INTO Player" + "VALUES" + "(?, ?, ?)"); insertplayer = conn.prepareStatement(insertPlayer); insertplayer.setString(1, firstname); insertplayer.setString(2, surname); insertplayer.setInt(3, attempts); int rowCount = insertplayer.executeUpdate(); System.out.println("rowCount=" + rowCount); System.out.println("Inserted record into the table..."); }
Thanks


LinkBack URL
About LinkBacks
Reply With Quote