The specified database user/password combination is rejected: org.hsqldb.HsqlException: unexpected token: NOT

别等时光非礼了梦想. 提交于 2021-01-29 05:04:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!