I have run into a problem with SQLITE and Java. I have looked through some of the answers here which suggested the programmers to use exceptions. Which I did use but my code is still giving me this one error
java.sql.SQLException: no such table: australia
and the records are not being updated on the created database:
Class.forName("org.sqlite.JDBC");
Connection connect = DriverManager.getConnection("jdbc:sqlite:playlist.sqlite");
System.out.println("Playlist db opened");
Statement saveStatement = connect.createStatement();
saveStatement.executeUpdate(makeTable);
try {
ResultSet getAllSameGenre = artStmt.executeQuery("SELECT * FROM tracklist WHERE genre = '" + storeGenre + "' ORDER BY RANDOM() LIMIT 10");
while(getAllSameGenre.next()){
int id = 1;
String title = getAllSameGenre.getString("title");
String artist = getAllSameGenre.getString("artist");
String genre = getAllSameGenre.getString("genre");
String album = getAllSameGenre.getString("album");
Statement finalRecord = connect.createStatement();
String storeTableName = playlistNameInsert.getText();
String record = "INSERT INTO " + storeTableName + " (id , title, artist , genre , album )" + "VALUES ( '" +id+title+artist+genre+album+ " ' ); " ;
finalRecord.executeUpdate(record);
id ++;
}
saveStatement.close();
connect.close();
}
catch(Exception e){
System.out.println(e);
}
Aucun commentaire:
Enregistrer un commentaire