• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Failed to start database exception  RSS feed

 
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have created a database, but have keep getting the error

SQLException: Failed to start database 'Database' with class loader sun.misc.Launcher$AppClassLoader@5c647e05, see the next exception for details.
Exception in thread "main" java.lang.NullPointerException
at dealornodeal.Database.createDB(Database.java:34)
at dealornodeal.DatabaseMain.main(DatabaseMain.java:10)

This is the code which has the main:



Database class:



I have imported derby.jar into the project library, I can't figure out why this doesn't work as I've made a previous database which I have based the code off

Thanks in advance
 
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put this statement at these lines and run the program again. And, post the exception stack trace here (this will have detailed message of what the problem is):

At lines 27, 49, 97 use this statement: ex.printStackTrace();
 
Caiz Austin
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, here is the exception stack trace:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at line 1, column 42.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeLargeUpdate(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source)
at dealornodeal.Database.createDB(Database.java:40)
at dealornodeal.DatabaseMain.main(DatabaseMain.java:10)
Caused by: ERROR 42X01: Syntax error: Encountered "(" at line 1, column 42.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatementOrSearchCondition(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
... 5 more
SQLException: Schema 'NAME' does not exist
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following statement in createDB() method:



VARCHAR2 is not a data type supported by Apache Derby. It should be VARCHAR. See the reference manual's Data types topic here: https://db.apache.org/derby/manuals/
 
Caiz Austin
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh thank you so much, such a silly mistake!
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Caiz Austin wrote:Oh thank you so much, such a silly mistake!



It was a mistake; not a silly one though. And, you are welcome!

EDIT: Oracle database does support a VARCHAR2 data type; and MySQL and PostgreSQL databases do not.
 
Caiz Austin
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again, now that I have the database methods working, my new Highscores table isn't appearing in the database even after refreshing



Are there any obvious reasons why? I've included derby.jar in the library folder
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

my new Highscores table isn't appearing in the database even after refreshing ...



I don't know where you are looking for it. Have tried looking under the "Other Schemas"?

Apache Derby comes with a command line tool called as "ij". Try using the ij and query the database, table and data. ij tool is easy to use and test database operations; one can create database, tables, etc., and also insert and query data in the table.

 
Caiz Austin
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Turns out the table did exist through my directory, it just won't appear on netbeans
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Caiz Austin wrote:Thanks! Turns out the table did exist through my directory, it just won't appear on netbeans



I didn't know you were using Netbeans IDE. Here is some info regarding viewing Derby database objects using NetBeans:
https://netbeans.org/kb/docs/ide/java-db.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!