How to fix Derby issue for Apache Netbeans IDE 15 - java

Unable to start server for Derby in IDE 15.
Tried to use Derby version 14, didn't work. Tried to change the location of the folder, didn't work.
When I press start server, it just hangs there, does no further processing.

Unresolved NetBeans Bug NETBEANS-3424 Unable to use Derby DB version 10.15.1.3 in Netbeans 11.2 looks relevant to your problem, though you are using different software releases of Derby, Java and NetBeans and your issue is with starting the server rather than establishing a connection.
I can reproduce the connection failure issue on NetBeans 15 using JDK 19 and Derby 10.16.1.1. After selecting the sample database connection jdbc:derby://localhost:1527/sample [app on APP] and selecting Connect... from the context menu this error is displayed:
Although that linked bug report is open and unresolved, a helpful user posted a workaround in the comments so that a suitable driver can be found:
In the Services panel in NetBeans select the entry Databases > Drivers > Java DB (Embedded), right click and select Customize... from the context menu.
The Customize JDBC Driver window will be displayed.
Click the Add... button three times to add the jars derbytools.jar, derbyshared.jar and derbyoptionaltools.jar from the lib directory of your Derby installation (which is named C:\Apache\db-derby-10.16.1.1-bin in my case, but yours is almost certainly something else).
After doing that your Customize JDBC Driver window for your Java DB (Embedded) driver should look similar to this:
Similarly, for the Databases > Drivers > Java DB (Network) entry add the jars derbytools.jar and derbyshared.jar so that your Customize JDBC Driver window looks like this:
After adding those jars to the two drivers you should immediately be able to connect to the APP database using the connection jdbc:derby://localhost:1527/sample [app on APP], and view its tables:
Notes:
You are using Java 8 which is unsupported in NetBeans 15. Update your IDE to use JDK 11 or greater.
You don't need to explicitly start the server by selecting Databases > Java DB > Start Server. Instead, just select Connect... for jdbc:derby://localhost:1527/sample [app on APP]

Related

Connecting Netbeans and MySQL but getting Big Integer error

So I am trying to add new connection to my Netbeans' database which is MySQL but I am getting Big Integer casting error can someone please help me?
In detail:
I right click on existing MySQL Server at localhost:3306 [root(disconnected) >> select connect and this pops up
Unable to connect to the MySQL server:
org.netbeans.api.db.explorer.DatabaseException: org.netbeans.api.db.explorer.DatabaseException: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long.
The server may not be running or your MySQL connection properties may not be set correctly. Do you want to edit your MySQL connection properties?
And my basic and admin properties are OK.
And I tried this too: Right click on databases >> select New Connection >> Driver: MySQL(Connector/J driver), JDBC URL: jdbc:mysql://localhost:3306/mysql , but when I test the connection it gives me the same error.
**MySQL server is running.
Thank you.
This is a JDBC Driver problem
I had a similar problem in netbeans. I resolved by removing the default driver (Connector/J driver) from the driver list under databases/drivers as shown below.
This happened with jdbc v8.0.12 on mysql v8.0
So after removing the default jdbc driver, I add an old version of the driver mysql-connector-java-5.1.47.
The connection the succeeded.
What is the version of your MySQL driver and your MySQL? If you want to use MySQL 8, for example, you could try to use a MySQL driver which supports MySQL 8.
Try updating your mysql driver.
To install the driver:
1° Go to the services tab, just after databases.
2° Right click on the drivers folder and select add new driver.
3° Click add and look for the .jar of the driver you downloaded.
Remove and clean the jdbc connector jar files already come with netbeans.
Add a new connector jar file to the jdbc library.
(You can download ==> mysql-connector-java/8.0.11
Try again, connection is going to be ok now.

MySQL to PostgreSQL migration: mysql connector

I am trying to migrate from MySQL to PostgreSQL and I have a Java-related problem that I am not able to fix. Full disclosure: I know little or nothing about Java, but the migration uses a Java-based script, so for me it becomes a configuration problem.
Short version of the problem:
The migration tool throws this exception:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
mysql-connector-java-5.0.8-bin.jar is already in the "JAVA_HOME\jre\lib\ext" directory, and I don't know how to solve this depencency problem.
Long version of the problem:
I was trying to migrate from MySQL to PostgreSQL. I checked the official postgresql documentation and I chose the free tool from entreprisedb (that can be downloaded here) to start the migration.
From the installation readme, they tell you that the mysql connector is not installed by default, but they also tell you the steps to solve this problem:
To enable MySQL connectivity, download MySQL's freely available JDBC driver from:
http://www.enterprisedb.com/downloads/third-party-jdbc-drivers
Place the mysql-connector-java-5.0.8-bin.jar file in the "JAVA_HOME\jre\lib\ext" directory (in my case: "C:\Program Files\Java\jre1.8.0_60\lib\ext\mysql-connector-java-5.0.8-bin.jar").
After configuring the tool properly and executing the .bat, this is the error I get:
Connecting with source MySQL database server...
MTK-11009: Error Connecting Database "MySQL Server"
DB-null: java.sql.SQLException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Stack Trace:
com.edb.MTKException: MTK-11009: Error Connecting Database "MySQL Server"
at com.edb.dbhandler.mysql.MySQLConnection.<init>(MySQLConnection.java:48)
at com.edb.common.MTKFactory.createMTKConnection(MTKFactory.java:250)
at com.edb.MigrationToolkit.createNewSourceConnection(MigrationToolkit.java:5982)
at com.edb.MigrationToolkit.initToolkit(MigrationToolkit.java:3346)
at com.edb.MigrationToolkit.main(MigrationToolkit.java:1700)
Caused by: java.sql.SQLException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.edb.Utility.processException(Utility.java:327)
at com.edb.dbhandler.mysql.MySQLConnection.<init>(MySQLConnection.java:47)
... 4 more
...which, to my understanding, probably means that mysql-connector-java-5.0.8-bin.jar is not found.
All the links I've found online regarding the error are specific for Eclipse or other IDEs, so I have not yet been able to solve this dependency problem.
SOLUTION
With the help of a friend that masters Java, this is the solution he achieved:
To start looking for the problem, we opened the runMTK.bat. The execution line reads:
cscript //nologo "..\etc\sysconfig\runJavaApplication.vbs" "..\etc\sysconfig\edbmtk-49.config" "-Dprop=..\etc\toolkit.properties -classpath -jar edb-migrationtoolkit.jar %*"
So then we opened this runJavaApplication.vbs, and in order to know the JAVA_EXECUTABLE_PATH that the program was using, we add this line to the script:
Wscript.Echo "JAVA_EXECUTABLE_PATH = " & JAVA_EXECUTABLE_PATH
With that info, we discover that the script is using the Java folder under C:\Program Files (x86), instead of the one under C:\Program Files (where I dropped the mysql jar). So we copy the mysql-connector-java-5.0.8-bin.jar in the \ext folder of the x86, and now the script works.
Word of advice: the script is throwing errors in half of the exported tables, so all the hassle may not be worth it. BUT if anyone is interested in making this migration script work from A to Z (which has been quite a challenge), here are the details:
HOW TO
Free tool (from entreprisedb):
http://www.enterprisedb.com/downloads/postgres-postgresql-downloads
Extract the files from the zip and fun the installer (ppasmeta-9.5.0.5-windows-x64.exe) as administrator.
To enable MySQL connectivity, download MySQL's freely available JDBC driver from:
http://www.enterprisedb.com/downloads/third-party-jdbc-drivers
Place the mysql-connector-java-5.0.8-bin.jar file in the "JAVA_HOME\jre\lib\ext" directory (in my case: "C:\Program Files\Java\jre1.8.0_60\lib\ext\mysql-connector-java-5.0.8-bin.jar").
The Migration Toolkit documentation can be found:
here (online doc): https://www.enterprisedb.com/docs/en/9.4/migrate/toc.html
or here (pdf doc): http://get.enterprisedb.com/docs/Postgres_Plus_Migration_Guide_v9.5.pdf
First: modify C:\Program Files\PostgresPlus\edbmtk\etc\toolkit.properties (Info here):
SRC_DB_URL=jdbc:mysql://SOURCE-HOST-NAME/SOURCE-DB-NAME
SRC_DB_USER=********
SRC_DB_PASSWORD=********
TARGET_DB_URL=jdbc:edb://localhost:5444/DESTINATION-DB-NAME
TARGET_DB_USER=enterprisedb
TARGET_DB_PASSWORD=********
Then: execute C:\Program Files\PostgresPlus\edbmtk\bin\runMTK.bat (Info here).
runMTK.bat -sourcedbtype mysql -targetdbtype enterprisedb -allTables YOUR_DB_SCHEMA
// ...or with a limited subset of tables:
runMTK.bat -sourcedbtype mysql -targetdbtype enterprisedb -tables TABLE1,TABLE2,TABLE3 YOUR_DB_SCHEMA
In order to get this subset of tables from MySQL:
SELECT
GROUP_CONCAT(TABLE_NAME)
FROM
information_schema.tables
WHERE
TABLE_SCHEMA = 'your_db_name'

Netbeans JDBC Error "Unable to find suitable driver" after JDK update

I recently upgraded my jdk from 6 to 8 when I installed Eclispe for Android. Now, in NetBeans when I try to right click on the node for the database and select connect, I get the following error:
"Unable to connect. Cannot establish a connection to jdbc:derby://localhost 1527:/Animal using org.apache.derby.jdbc.ClientDriver (Unable to find a suitable driver)."
So far, I have tried uninstalling Eclipse and reinstalling Netbeans and that didn't work. I'm not getting any errors in my code aside from a popup that says the project is missing resources. Could someone please provide instructions on how to solve this issue? I've looked on the NetBeans' website and on this forum and there doesn't seem to be a clear procedure for resolving this.
If that's not a typo on your part your JDBC URL is malformed:
jdbc:derby://localhost 1527:/Animal
That's what I copied from your question. However, the correct URL would look like
jdbc:derby://localhost:1527/Animal
With the colon before the port, not after.
At Netbeans already states that this driver was tried but failed I'm quite sure it's got nothing to do with your driver setup. But if you want todouble check:
Here's a tutorial on how to add and enable oracle thin driver. I'd think it will work the same way for derby drivers.
I solved it in the following way:
The driver that you use to connect to the database may have deleted it or changed your address. So that:
You must put it back in the address that was indicated in the databases driver>
Drivers> (driver you use to connect)
Indicate the new address where you are
The error is in the path you are specifying in the driver or in the connection.
I had the same problem when trying to connect MySQL server to NetbeansIDE. Turns out the jdbc connector was an old version. You can read about the MySQL connector versions here. Either
download the latest version of MySQL connector or
add a new driver.
My problem was solved by adding a new driver.

Conflict between Netbeans IDE 8.0 and UCanAccess?

I have to define a new Driver in the Netbeans "Services" Tab
Services->Databases->Drivers->new Driver...
because I want use the "Entity Classes from Database"-Wizard in context with UCanAccess.
1st step: "new Driver" does work (only declaration ;-) )
Driver File(s): f:\WorkspaceNetbeans\MSAccessDB\lib\UCanAccess-2.0.4-bin\ucanaccess-2.0.4.jar
Driver Class: net.ucanaccess.jdbc.UcanaccessDriver
Name:msaccess
2nd step: "Connect using..."
JDBC URL: jdbc:ucanaccess://F:/WorkspaceNetbeans/MSAccessDB/data/Datenbank2.accdb
"User Name" and "Password" leave blank
The "Test Connection"-Button results in Error Message:
Cannot establish a connection to
jdbc:ucanaccess://F:\WorkspaceNetbeans\MSAccessDB\data\Datenbank2.accdb using
net.ucanaccess.jdbc.UcanaccessDriver (Could not initialize class
net.ucanaccess.jdbc.UcanaccessDriver)
I've got the newest ucanaccess from http://ucanaccess.sourceforge.net/site.html
ucanaccess-2.0.4.jar, commons-lang-2.6.jar, commons-logging-1.0.4.jar, hsqldb.jar, jackcess-2.0.3.jar in the Netbeans Classpath.
The old fashion way to connect via jdbc to ucanaccess works fine.
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String connectString = "jdbc:ucanaccess://" + "f:/WorkspaceNetbeans/MSAccessDB/data/Datenbank2.accdb";
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection conn = DriverManager.getConnection(connectString, "", "");
conn.createStatement().execute("CREATE TABLE example1 (id COUNTER PRIMARY KEY,descr text(400), number numeric(12,3), date0 datetime) ");
}
The same connection string also works fine make DBeaver able to connect to the MSAccess db.
My set up:
Windows 7 Professional 64 bit
Microsoft Office 2013
NetBeans IDE 8.0
Java 1.8
The problem is similar to: "Conflict between JT400 and UCanAccess?" Conflict between JT400 and UCanAccess?
but the answers there don't help with my problem.
Any ideas to solve my problem?
UCanAccess 2.0.4.1 has been released, now you can configure UCanAccess as NetBeans service.
As explained in the UCanAccess web site (tab 'jdbc client tools') you have to:
-in the field Driver File(s), add ucanaccess.jar and all dependencies. I've upgraded the commons-logging in the UCanAccess distribution to the 1.1.1, so you can use that jar with NetBeans8.
-use the following pattern for the jdbc url:
jdbc:ucanaccess://;showschema=true
Showschema connection property must be setted to true.
I was wrong, it wasn't a tricky task but...
To establish the connection you have to list in the Driver File(s) :
ucanaccess-2.0.4.jar,
commons-lang-2.6.jar,
hsqldb.jar,
jackcess-2.0.3.jar
AND
a different version of commons-logging that you can find it in NetBeans:
NetBeans 8.0\ide\modules\org-apache-commons-logging.jar (the commons-logging in the UCanAccess distribution is in conflict with that used by NetBeans)
But unfortunatly, after establishing the connection, you won't be able to execute queries through this IDE, because of a trivial bug in the UcanaccessDatabaseMetadata which hasn't effect with the other IDE jdbc clients I tested (Openoffice, Libreoffice, DBeaver, Squirrel, SQLeo and so on) .
So, to do this, you have to wait some days (I think I'll post a patched Ucanaccess 2.0.4.1 next week). Also, I'll add a note about UCanAccess configuration as NetBeans service in the UCanAccess web site.

JAVA EE 7 First cup tutorial, can't install Glassfish 4 update center

Well I was trying to follow the first cup tutorial, but I'm stuck with a Glassfish error.
I'm supposed to this:
1.2.4 Getting the Latest Updates to the Tutorial
Check for any updates to this tutorial by using the Update Center
included with the Java EE 7 SDK.
1.2.4.1 Update the Tutorial Through the Update Center Open the Update Center and check for any updates to the tutorial.
In NetBeans IDE, select the Services tab and expand the Servers node.
Right-click the GlassFish Server instance and select View Update
Center to display the Update Tool. In the tree, select Available
Updates to display a list of updated packages. Look for updates to the
First Cup for Java EE 7 (javaee-firstcup-tutorial) package. If there
is an updated version of First Cup, select First Cup 7.0 for Java EE 7
(javaee-firstcup-tutorial) and click Install.
The thing is, when I try to open the Update Center, this is what I get:
The software needed for this command (updatetool) is not installed.
If you choose to install Update Tool, your system will be automatically
configured to periodically check for software updates. If you would like
to configure the tool to not check for updates, you can override the
default behavior via the tool's Preferences facility.
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:658)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at com.sun.pkg.client.Image.checkRepositoryConnection(Image.java:1225)
at com.sun.pkg.client.Catalog.refresh(Catalog.java:132)
at com.sun.pkg.client.Image.refreshCatalogs(Image.java:1627)
at com.sun.pkg.client.Client.main(Client.java:109)
When this tool interacts with package repositories, some system information
such as your system's IP address and operating system type and version
is sent to the repository server. For more information please see:
http://wikis.oracle.com/display/updatecenter/UsageMetricsUC2
Once installation is complete you may re-run this command.
Would you like to install Update Tool now (y/n):
C:\Program Files\glassfish-4.0>"C:\Program Files\Java\jdk1.7.0_40\bin\java" -Dimage.path="C:\Program Files\glassfish-4.0\bin\\.." -jar "C:\Program Files\glassfish-4.0\bin\\..\pkg/lib/pkg-client.jar" refresh
C:\Program Files\glassfish-4.0>"C:\Program Files\Java\jdk1.7.0_40\bin\java" -Dimage.path="C:\Program Files\glassfish-4.0\bin\\.." -jar "C:\Program Files\glassfish-4.0\bin\\..\pkg/lib/pkg-bootstrap.jar" "C:\Users\Fabio\AppData\Local\Temp\pkg-bootstrap11073.props"
Proxy: Using system proxy settings.
Input/output error: Connection reset
Could not download application packages. This could be because:
- a proxy server is needed to access the internet. Please ensure that
the system proxy server settings in your Internet Options control panel
(under Connections:LAN Settings) are correct, or set the HTTP_PROXY
environment variable to the full URL of the proxy server.
- the package server or network connection is slow.
If you are getting time out errors you can try setting the
PKG_CLIENT_CONNECT_TIMEOUT and PKG_CLIENT_READ_TIMEOUT
environment variables and try again. For example to increase
the timeouts to 300 seconds set them to 300
- the package server is down or otherwise inaccessible or it is
generating invalid data. Please contact the provider of the package
server.
This may be a problem with the slow GlassFish update server. Here are some steps you can try:
You should retry first to see if the error occurs again. You can start a cmd, navigate to the \glassfish\bin directory and run updatetool.bat so you can see the output which is printed after the one you posted.
If you are behind a proxy you should make sure it is setup correctly in the system settings.
You can also try to install the updates through the GlassFish admin console. Start your GlassFish instance and navigate to http:\\localhost:4848. On the bottom of the left menu click on Updatetool. There you can choose and install the desired updates.
Another option is to change the timeouts of the pkg tool. To set the timeout to 300 seconds do the following in a cmd (on Windows):
set PKG_CLIENT_CONNECT_TIMEOUT=300
set PKG_CLIENT_READ_TIMEOUT=300
Your last (ok, there may be other ones) option is to just skip the update process and do the tutorial with the current version. It should work anyway and I can see in my GlassFish update center that there is only an update for the tutorial documentation at the moment.
Just set this line into cmd (like administrator):
set PKG_CLIENT_CONNECT_TIMEOUT=300
set PKG_CLIENT_READ_TIMEOUT=300
Maybe the firstcup example is already existed in the install directory. Try to find it in the directory_install_glassfish/glassfish4/docs. The mine contain even javaee-tutorial and firstcup. For the next part, you maybe continue after guide in firstcup.pdf with the part of : Creating Your First Java by create archetype of java project. Good luck !
For the lazy of you the pkg Unix command is:
export PKG_CLIENT_CONNECT_TIMEOUT=300
export PKG_CLIENT_READ_TIMEOUT=300
After being stuck for a while on the installation of GlassFish update server from Netbeans (in my company network, proxy issues), I got it this way:
- Advanced System Settings > System Properties window > Advanced tab, New System Variable: http_proxy, http://username:password#your_proxy:your_port
- Netbeans (running as admin just in case), Services > Server > Glassfish Server > Right button View Domain Update Center, then install
It worked for me, Hope it helps!

Categories