本文介紹了HSQLDB:java.sql.SQL語(yǔ)法錯(cuò)誤異常:用戶(hù)沒(méi)有權(quán)限或找不到對(duì)象的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我發(fā)現(xiàn)這個(gè)錯(cuò)誤在整個(gè)互聯(lián)網(wǎng)上多次出現(xiàn),但我根本沒(méi)有找到我的情況的解決方案。我有一個(gè)HSQL數(shù)據(jù)庫(kù)–我已經(jīng)成功地連接到數(shù)據(jù)庫(kù)中的一個(gè)表。我繼續(xù)在數(shù)據(jù)庫(kù)中創(chuàng)建另一個(gè)表–使用適當(dāng)修改的完全相同的Java代碼,但是它會(huì)出現(xiàn)錯(cuò)誤:java.sql.SQLSynaxErrorException:USER缺乏特權(quán)或找不到對(duì)象:USER。
我發(fā)現(xiàn)在我的文件存儲(chǔ)腳本中有創(chuàng)建產(chǎn)品表的代碼,但是我創(chuàng)建用戶(hù)表的方式與創(chuàng)建產(chǎn)品表的方式相同-使用HSQL數(shù)據(jù)庫(kù)管理器。
這是我的錯(cuò)誤代碼:
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: USER
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at hb00294_eCommerce_com1028.data.LoginWindow.validateUserDetails(LoginWindow.java:129)
at hb00294_eCommerce_com1028.data.LoginWindow.access$4(LoginWindow.java:121)
at hb00294_eCommerce_com1028.data.LoginWindow$2.mouseClicked(LoginWindow.java:113)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: USER
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.SchemaManager.getTable(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source)
at org.hsqldb.ParserDQL.XreadFromClause(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 37 more
這是我的文件存儲(chǔ)腳本:
SET DATABASE UNIQUE NAME HSQLDB4D9B227D23
SET DATABASE GC 0
SET DATABASE DEFAULT RESULT MEMORY ROWS 0
SET DATABASE EVENT LOG LEVEL 0
SET DATABASE TRANSACTION CONTROL LOCKS
SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED
SET DATABASE TRANSACTION ROLLBACK ON CONFLICT TRUE
SET DATABASE TEXT TABLE DEFAULTS ''
SET DATABASE SQL NAMES FALSE
SET DATABASE SQL REFERENCES FALSE
SET DATABASE SQL SIZE TRUE
SET DATABASE SQL TYPES FALSE
SET DATABASE SQL TDC DELETE TRUE
SET DATABASE SQL TDC UPDATE TRUE
SET DATABASE SQL TRANSLATE TTI TYPES TRUE
SET DATABASE SQL CONCAT NULLS TRUE
SET DATABASE SQL UNIQUE NULLS TRUE
SET DATABASE SQL CONVERT TRUNCATE TRUE
SET DATABASE SQL AVG SCALE 0
SET DATABASE SQL DOUBLE NAN TRUE
SET FILES WRITE DELAY 500 MILLIS
SET FILES BACKUP INCREMENT TRUE
SET FILES CACHE SIZE 10000
SET FILES CACHE ROWS 50000
SET FILES SCALE 32
SET FILES LOB SCALE 32
SET FILES DEFRAG 0
SET FILES NIO TRUE
SET FILES NIO SIZE 256
SET FILES LOG TRUE
SET FILES LOG SIZE 50
CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e'
ALTER USER SA SET LOCAL TRUE
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
SET SCHEMA PUBLIC
CREATE MEMORY TABLE PUBLIC.PRODUCT(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,TITLE VARCHAR(50),DESCRIPTION VARCHAR(90),INFORMATION VARCHAR(200),TYPE VARCHAR(50),PRICE DOUBLE,SHIPPINGPRICE DOUBLE)
ALTER TABLE PUBLIC.PRODUCT ALTER COLUMN ID RESTART WITH 15
ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1
SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC
GRANT DBA TO SA
SET SCHEMA SYSTEM_LOBS
INSERT INTO BLOCKS VALUES(0,2147483647,0)
SET SCHEMA PUBLIC
INSERT INTO PRODUCT VALUES(1,'a','b','c','MISCELLANEOUS',4.0E0,4.0E0)
我不確定是訪問(wèn)權(quán)限有問(wèn)題,還是它沒(méi)有識(shí)別出USER表的存在–我已經(jīng)創(chuàng)建了一個(gè)方法來(lái)顯示數(shù)據(jù)庫(kù)中的所有表名,它確實(shí)顯示了PRODUCT,但沒(méi)有顯示USER。有什么解決這個(gè)問(wèn)題的建議嗎?
我希望我已經(jīng)提供了足夠的信息–如果還需要任何進(jìn)一步的信息,請(qǐng)告訴我,我真的很感謝你們的幫助。
推薦答案
如果您實(shí)際創(chuàng)建了一個(gè)名為User的表,它將與其他表一起顯示在.script文件中。
可能您確實(shí)在以后的會(huì)話(huà)中創(chuàng)建表,但沒(méi)有關(guān)閉數(shù)據(jù)庫(kù)或執(zhí)行檢查點(diǎn),因此額外的CREATE TABLE USER…未保存報(bào)表。
這篇關(guān)于HSQLDB:java.sql.SQL語(yǔ)法錯(cuò)誤異常:用戶(hù)沒(méi)有權(quán)限或找不到對(duì)象的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,