我正在使用HSQLDB通过IDEA连接到我的数据库。但是我遇到了错误-即使输入正确,用户名/密码也被拒绝:
拒绝指定的数据库用户/密码组合:org.hsqldb.HsqlException:意外令牌:NOT
之前数据库连接成功,但是在我修改了其中一个表的SQL代码之后,该错误开始发生
用于建立连接的代码如下:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatabaseConnectionFactory {
private static Connection connection = null;
private DatabaseConnectionFactory() {
// Exists only to defeat instantiation.
}
public static Connection getConnection() {
if(connection == null) {
try {
DatabaseConnectionFactory.connection = DriverManager.getConnection(
"jdbc:hsqldb:file:db_data/myDBfilestore;ifexists=true;shutdown=true", "SA", "");
} catch (SQLException e) {
e.printStackTrace();
}
}
return connection;
}
public static void closeConnection() {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
用于创建表的SQL代码是(修改后):
create table SONG
(
ID INTEGER default 1 identity,
ALBUM_ID INTEGER not null,
NAME VARCHAR(128) not null,
LENGTH INTEGER not null
);
create unique index SONG_ID_UINDEX
on SONG (ID);
create unique index SYS_IDX_SONG_PK_10117
on SONG (ID);
alter table SONG
add constraint SONG_PK
primary key (ID);