Try something like the following:
String dataSourceName = "my_ODBC_DSN_name";
String username = "username";
String password = "password";
String url = "jdbc:odbc:" + dataSourceName;
Connection con = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url, username, password);
PreparedStatement pst = con.prepareStatement("INSERT INTO Scores "
+ "(Name, Difficulty, Characters, Accuracy, Time, Score) "
+ "VALUES (?, ?, ?, ?, ?, ?)");
pst.setString(1, "Name String");
pst.setString(2, "Difficulty String");
pst.setInt(3, 20);
pst.setString(4, "Acurracy String");
pst.setString(5, "Time String");
pst.setString(6, "Score String");
pst.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
if (con != null)
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
You have to set up an ODBC DSN first in the Windows Control Panel. It's in Control Panel -> Administrative Tools -> Data Sources.
As an aside to your main question, I also second Russ Cam's opinion that you should probably revise your Database schema, so that you use the appropriate column types for the Time and Score columns and possibly for Accuracy and Difficulty. In a normalized design, "Name" would also be a foreign key (something like player_id) to another table which will hold the details for each player.