【发布时间】:2024-01-22 14:09:01
【问题描述】:
对于学校项目,我正在使用一个简单的数据库(名称、艺术家、长度、专辑......)制作音乐播放器,我已经完成了 1/2,但现在当我尝试连接到学校时数据库它给了我一个错误:
ORA-00933: SQL command not properly ended.
我已经检查了我的代码一千次,但没有发现错误。 这里是连接部分(和sql命令):
try{
String name=display.getText();
String url="jdbc:oracle:thin:@193.2.139.248:1521:ers";
Class.forName("oracle.jdbc.OracleDriver").newInstance();
Connection pb=DriverManager.getConnection(url,"username", "password");
Statement sta=pb.createStatement();
ResultSet rs=sta.executeQuery("select Song.Name, Artist.name from Song,Album,Artist where Song.Album_ID=Album.ID and Album.Artist_fk=Artist.ID and Song.name="+name);
if(rs.next()){
JOptionPane.showMessageDialog(rootPane, rs);
}
else{
JOptionPane.showMessageDialog(rootPane, "Song not found");
}
pb.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(rootPane, e.getMessage());
}
非常感谢!
【问题讨论】:
-
试试这个,executeQuery("select Song.Name, Artist.name from Song,Album,Artist where Song.Album_ID=Album.ID and Album.Artist_fk=Artist.ID and Song.name=" +name+";");
标签: java mysql sql netbeans database-connection