问题
I am using HSQLDB to connect to my database via IDEA. However I am getting the error - username/password rejected, even though I entered correctly:
The specified database user/password combination is rejected: org.hsqldb.HsqlException: unexpected token: NOT
The database connection was successful before, but after had I modified the SQL code for one of the tables, the error started to occur
The code for establishing the connection is below:
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();
}
}
}
}
The SQL code for creating the table is (after modification):
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);
来源:https://stackoverflow.com/questions/56042794/the-specified-database-user-password-combination-is-rejected-org-hsqldb-hsqlexc