Unable to Run Database App [message #1700760] |
Mon, 06 July 2015 16:20 |
Eclipse User |
|
|
|
I'm in the process of teaching myself how to write data driven apps in Java, but I've run into a bit of a snag. When I try to run my code, I get the following error:
"998 is not a valid line number in com.mysql.jdbc.SQLError"
The following is the code I wrote:
package net.xtraordinayr.mysqldemo;
import java.sql.*;
public class DemoDriver {
public static void main(String[] args) {
try{
// Load the driver
Class.forName("com.mysql.jdbc.Driver");
// 1. Get a connection to the database
Connection mySqlConn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/starfleetacademydb", "root", "ncc_1701-f");
// 2. Create a statement
Statement demoQuery = mySqlConn.createStatement();
// 3. Execute SQL query
ResultSet mySqlRs = demoQuery.executeQuery("SELECT * FROM student_table");
// 4. Process the result set
System.out.println(mySqlRs.getString("rankID") + " " +
mySqlRs.getString("lastName") + " " +
mySqlRs.getString("firstName"));
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
Is there any way to get past this issue so that I can determine if my code is working?
TekknoDraykko
|
|
|
Powered by
FUDForum. Page generated in 0.05361 seconds