Karina S
Karina S

Reputation: 21

Cannot connect with a backup of a derby database using Netbeans or ij

I back up regularly a derby database, that is on another server, simply by copying the location of the Derby database. So I have many backups depending on the date.

Now I am trying to connect to one of those backups from my computer, after installing Netbeans and Java 1.6 (becuase the app runs on this verion) and also installing derby.

The app connects with Java DB Network (clientDriver) and the connection URL is:

jdbc:derby://localhost:1527/C:Derby.DB

The error that I get is: Unable to connect. Cannot establish a connection to database using org.apache.derby.jdbc.ClientDriver (DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ040, SQLERRMC: fail to start database with class loader sun.misc.Launcher$AppClassLoader@610455d6, see the next exception for details.::SQLSTATE:X0Y32

Ive investigated a lot and tried many options with no solution.

Please help! Thank you

Ive already tried to connect from ij and get the exact same error.

Ive tried to connect from the server and re-direct to the back database and get the exact same error.

Also, when I try to connect through the Embedded Driver, I get this error:

ij> connect 'jdbc:derby:C:/database';

---------------------------------------------------------------- Tue Apr 02 08:39:43 COT 2019: Iniciando instancia f81e0010-0169-dae4-8f03-00000e572d50 de Derby, versi¾n The Apache Software Foundation - Apache Derby - 10.12.1.1 - (1704137): in the database directory using sun.misc.Launcher$AppClassLoader@66d3c617 Loaded from file:/C:/db-derby-10.12.1.1-bin/db-derby-10.12.1.1-bin/lib/derby.jar java.vendor=Oracle Corporation java.runtime.version=1.8.0_201-b09 user.dir=C:\ os.name=Windows 10 os.arch=amd64 os.version=10.0 derby.system.home=null Cargador de clases de base de datos iniciado - derby.database.classpath='' ---------------------------------------------------------------- Tue Apr 02 08:39:43 COT 2019: Cerrando la instancia f81e0010-0169-dae4-8f03-00000e572d50 en el directorio de base de datos C:\database con cargador de clases sun.misc.Launcher$AppClassLoader@66d3c617 Tue Apr 02 08:39:43 COT 2019 Thread[main,5,main] Cleanup action starting java.sql.SQLException: Cannot establish a connection to database using sun.misc.Launcher$AppClassLoader@66d3c617, consulte la excepci¾n siguiente para obtener mßs informaci¾n. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.derby.impl.tools.ij.ij.dynamicConnection(Unknown Source) at org.apache.derby.impl.tools.ij.ij.ConnectStatement(Unknown Source) at org.apache.derby.impl.tools.ij.ij.ijStatement(Unknown Source) at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source) at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source) at org.apache.derby.impl.tools.ij.Main.go(Unknown Source) at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source) at org.apache.derby.impl.tools.ij.Main.main(Unknown Source) at org.apache.derby.tools.ij.main(Unknown Source) Caused by: ERROR XJ040: Cannot establish a connection to database using sun.misc.Launcher$AppClassLoader@66d3c617, consulte la excepci¾n siguiente para obtener mßs informaci¾n. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 23 more Caused by: ERROR X0Y32: Statement 'getUDTs' already exists in Schema 'SYS'. 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.catalog.DataDictionaryImpl.addSPSDescriptor(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.createSPSSet(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.createSystemSps(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.updateMetadataSPSes(Unknown Source) at org.apache.derby.impl.sql.catalog.DD_Version.handleMinorRevisionChange(Unknown Source) at org.apache.derby.impl.sql.catalog.DD_Version.upgradeIfNeeded(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.loadDictionaryTables(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase$5.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.db.BasicDatabase.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection$4.run(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.jdbc.EmbedConnection.startPersistentService(Unknown Source) ... 20 more ============= begin nested exception, level (1) =========== java.sql.SQLException: Statement 'getUDTs' already exists in Schema 'SYS'. 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.EmbedConnection.bootDatabase(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.derby.impl.tools.ij.ij.dynamicConnection(Unknown Source) at org.apache.derby.impl.tools.ij.ij.ConnectStatement(Unknown Source) at org.apache.derby.impl.tools.ij.ij.ijStatement(Unknown Source) at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source) at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source) at org.apache.derby.impl.tools.ij.Main.go(Unknown Source) at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source) at org.apache.derby.impl.tools.ij.Main.main(Unknown Source) at org.apache.derby.tools.ij.main(Unknown Source) Caused by: ERROR X0Y32: Statement 'getUDTs' already exists in Schema 'SYS'. 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.catalog.DataDictionaryImpl.addSPSDescriptor(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.createSPSSet(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.createSystemSps(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.updateMetadataSPSes(Unknown Source) at org.apache.derby.impl.sql.catalog.DD_Version.handleMinorRevisionChange(Unknown Source) at org.apache.derby.impl.sql.catalog.DD_Version.upgradeIfNeeded(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.loadDictionaryTables(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase$5.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.db.BasicDatabase.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection$4.run(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.jdbc.EmbedConnection.startPersistentService(Unknown Source) ... 20 more ============= end nested exception, level (1) =========== ============= begin nested exception, level (2) =========== ERROR X0Y32: Statement 'getUDTs' already exists in Schema 'SYS'. 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.catalog.DataDictionaryImpl.addSPSDescriptor(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.createSPSSet(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.createSystemSps(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.updateMetadataSPSes(Unknown Source) at org.apache.derby.impl.sql.catalog.DD_Version.handleMinorRevisionChange(Unknown Source) at org.apache.derby.impl.sql.catalog.DD_Version.upgradeIfNeeded(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.loadDictionaryTables(Unknown Source) at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase$5.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.db.BasicDatabase.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection$4.run(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.impl.jdbc.EmbedConnection.startPersistentService(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source) at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.derby.impl.tools.ij.ij.dynamicConnection(Unknown Source) at org.apache.derby.impl.tools.ij.ij.ConnectStatement(Unknown Source) at org.apache.derby.impl.tools.ij.ij.ijStatement(Unknown Source) at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source) at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source) at org.apache.derby.impl.tools.ij.Main.go(Unknown Source) at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source) at org.apache.derby.impl.tools.ij.Main.main(Unknown Source) at org.apache.derby.tools.ij.main(Unknown Source) ============= end nested exception, level (2) =========== Cleanup action completed ERROR XJ040: Cannot establish a connection to database using sun.misc.Launcher$AppClassLoader@66d3c617, consulte la excepcion siguiente para obtener mas informacion. ERROR X0Y32: Statement 'getUDTs' already exists in Schema 'SYS'.

Upvotes: 1

Views: 1262

Answers (2)

Karina S
Karina S

Reputation: 21

Im posting this because finally I could recover the corrupted table and for somenone that would find this helpful.

What I did after replacing these files: c230.dat, c241.dat and c251.dat

I investigated how to recover corrupted tables and found this great page:

https://givemethechills.com/recovering-a-corrupted-embedded-apache-derby-database-after-an-error-xj040-or-if-you-get-an-error-xsdg2/

That basically gave these steps:

  1. Download the latest derby bin.
  2. Add DerbyRecovery-0.0.1-SNAPSHOT.jar to the ij classpath
  3. Run dataFileVTI.sql (remember to change the route to the database in the connect string)
  4. Enter ij and connect to the database using upgrade=true
  5. Use call SYSCS_UTIL.SYSCS_REGISTER_TOOL('customTool',true,'RawDBReader', 'CONTROL','RAW_','c:db','','APP',null); -> change the db route, password, bootpassword and schema
  6. Check with select * from raw_app.table1;

I only got the 3rd step and then decided to restore the database with this command in ij:

jdbc:derby:sample;restoreFrom=c:\Derby.DB

and this worked. After this I could access the table that I needed, with all the records.

So probably only running this command in ij worked after replacing the files, but I'm posting everything I did just in case.

Thanks to all that helped! Karina S.

Upvotes: 1

skomisa
skomisa

Reputation: 17363

[This is not really a solution, but is too long to post as a comment.]

Someone else had the same problem as you (ERROR X0Y32: Statement 'getUDTs' already exists...). See Bug Report DERBY-5371: Database fails to boot, complaining that the getProcedureColumns() system procedure already exists

The final comment in the thread states:

I had a customer who was also hit by this problem on an old database, with the same error that Andreas reported.

Caused by: java.sql.SQLException: Statement 'getUDTs' already exists in Schema 'SYS'.

Running the command:

values syscs_util.syscs_get_database_property( 'DataDictionaryVersion' )

returned 10.5.

I used the same trick of loading fresh c230.dat, c241.dat and c251.dat files in order to get the database to boot.

I'm not sure what exactly has to be done to load "fresh c230.dat, c241.dat and c251.dat files in order to get the database to boot", but if that makes sense to you it might be worth trying.

Upvotes: 0

Related Questions