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.
Related
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]
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.
I'm using the mariadb-java-client-1.5.7.jar connector for MariaDB, and it does not work.
Here's the connection code:
public DataAccess() throws SQLException, ClassNotFoundException {
this.driver = "org.mariadb.jdbc.Driver";
this.host = "jdbc:mariadb://localhost/bluebank";
this.user = "root";
this.password = "";
Class.forName(this.driver);
this.conn = DriverManager.getConnection(this.host, this.user, this.password);
}
I get:
java.sql.SQLException: No suitable driver found for jdbc:mariadb://localhost/bluebank
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at DAO.DataAccess.<init>(DataAccess.java:31)
Apart from adding as an external jar to the libraries, I've added it as a driver to the databases in (Services) in Netbeans. Also, if I remove the Class.forName(), it doesn't work as well.
Had something similar today. Worked in Eclipse, did not with pure Java.
For me it was important to have
Class.forName ("org.mariadb.jdbc.Driver");
to make it work everywhere.
You forgot the port number of your database :
this.host = "jdbc:mariadb://localhost:port_number/bluebank";
Make sure that your db connector jar, exist in the your jar libraries: https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/
You can learn more here :
Connect to MariaDB from Java application in NetBeans on Linux (Mageia)
Hope this can help you
replace mariadb in the url with mysql:
I had this Problem myself: the solution was quite simple... MariaDB is basically still MySQL. In the Url you are using to connect to the Database (jdbc:mariadb://localhost:3306) you can therefore just use jdbc:mysql://localhost:3306 <- i just replaced mariadb with mysql. It is still running on a mariadb server but it works so dont change it ;)
Still i dont know why none of the other solutions have worked but at least it is a solution
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.
I'm trying to build a simple jdbc sql example. it's 1 class. I have both jdbc driver jars referenced it's runtime is JavaSE-1.6. It connects to a database I already have setup using this code...
// Load the JDBC driver
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// Create a connection to the database
connection = DriverManager
.getConnection("jdbc:sqlserver://localhost:1433;database=AboardTestDB;integratedSecurity=true");
System.out.println("Connected DB successfully");
// STEP 4: Execute a query
// writes the tables in local and not on GANESHN1\SQLSERVER2008
System.out.println("Creating table in given database...");
Statement stmt = connection.createStatement();
And the thing is it worked before. It worked beautifully. But a colleague of mine was having trouble with it. so I removed a jar to get the same error as him. but when I put it back it gave me this error message (again)
Dec 20, 2013 9:50:53 AM com.microsoft.sqlserver.jdbc.SQLServerConnection
SEVERE: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
Exception in thread "main" java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.(SQLServerConnection.java:304)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1011)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at sqldriver.doConnection(sqldriver.java:23)
at sqldriver.main(sqldriver.java:59)
Everything else has stayed the same. I tried restarting, unstalling/reinstalling, creating a new project, trying different JRE's nothing.
Is there something I'm missing here? something else I can try?
never mind! I got it working again by removing one of the jars. The thing is, I had them both in there and it was working just fine before :P
Mysterious