No suitable driver found on glassfish4 - java

I am having a no suitable driver found issue on Ubuntu + Glassfish 4. I am trying to connect to a Postgres instance on Amazon RDS. Except I have added the required driver to everywhere I know:
-Domain1 lib
-glassfish lib
-java-7-oracle lib
Please help me. I have no idea why this is not working.
Thanks in advance...

I'm such an idiot. JDBC string was wrong due to bad copy-paste! That said - would be nice if GF was all "hey man your JDBC string looks bogus".

Related

Impala driver class not being found through Jaydebeapi Connection

I recently switched over from using a PC to a Mac and now for whatever reason one of my Impala drivers that worked fine is no longer found when run in Python. I keep receiving this error every time I run the script : "java.lang.RuntimeException: Class com.cloudera.impala.jdbc41.Driver not found". Please see code snippet for my connection below.
c = jaydebeapi.connect
(jclassname='com.cloudera.impala.jdbc41.Driver',
url='jdbc:impala://cloudera-impala-proxy.live.bi.xxx/;AuthMech=3;ssl=1;',
driver_args=['xxx', self.dwh_password], jars='/Users/xxx/Desktop/ImpalaJDBC41 2.jar')
Any help or suggestions are appreciated, I feel like I'm going crazy trying to get this to work.
Did you check do you have the ImpalaJDBC***.jar in your new machine.
Please check properly weather it's available at classpath/build path or not.
Edit:
You can use hive jdbc jar as well to connect with impala , just use the port of impala rather hive in jdbc url.
Looking at this error means your jar is corrupt.
First check your impalaJDBC jar
java -jar ImpalaJDBC<version>.jar
If it gives you error that means your jar is corrupt.
Download the correct jar from cloudera

No suitable driver found for jdbc:mariadb (Netbeans)

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

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.

no suitable driver for jdbc:oracle:thin:#localhost:1521:servicename

I know, this has already been posted but none of the solutions worked. I am really stuck at this point. I am working on installation of oracle 12c SOA suite. I am installing PIP3.4. However, when I run from command, I get this error:
no suitable driver for jdbc:oracle:thin:#localhost:1521:servicename.
I also tried following URL:
no suitable driver for jdbc:oracle:thin:#localhost:1521/servicename
ojdbc6 and ojdbc7 are already present there. I am using Oracle SOA 12C and jdk1.8.0_51. Any help will be appreciated.
Try connecting to the database using SQLPLUS and also using fully qualified URL.
sqlplus scott/tiger#"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"
Fully qualified URL = jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))

Firebird connection with java

I have installed Firebird 2.1 on windows Xp and using firebirdsql.jdbc-2.1.6 driver to connect with java. Code:
Class.forName("org.firebirdsql.jdbc.FBDriver");
connection = DriverManager.getConnection(
"jdbc:firebirdsql://localhost/3050//C:/firebird/database/EMPLOYEE.FDB",
"test","test");
I am getting following error:
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544375.
unavailable database
Reason: unavailable database at
org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:122) at
org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:140) at
java.sql.DriverManager.getConnection(DriverManager.java:525) at
java.sql.DriverManager.getConnection(DriverManager.java:171)
Please help.
Problem solved:
Actually I had problem with jar file that I got from
http://mirrors.ibiblio.org/pub/mirrors/maven2
I downloaded jaybird-full-2.1.6.jar from firebird offical website and problem got solved.
Correct URL is
"jdbc:firebirdsql://localhost:3050/C:\\firebird\\database\\EMPLOYEE.FDB"
I tried this URL earlier also but it was not working beacuse of jar issue.
As #Thorbjørn Ravn Andersen observes, your Jaybird JDBC URL is incorrect. The syntax is jdbc:firebirdsql:[host[/port]:]<database>. You need a colon between the host/port and the database path. Perhaps something like this:
"jdbc:firebirdsql://localhost/3050:C:\\firebird\database\EMPLOYEE.FDB"
Oops, I left in the leading slashes; try this:
"jdbc:firebirdsql:localhost/3050:C:\\firebird\database\EMPLOYEE.FDB"
Addendum: You might run through the common errors list. Also, my firebird database files end in .fdb, but the FAQ mentions .gdb. It can't hurt to check.
From https://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html#pure-java-default
Default URL format:
"jdbc:firebirdsql://host[:port]/<database>"
Deprecated, but still supported legacy URL format:
"jdbc:firebirdsql:host[/port]:<database>"
Then, the correct URL should be:
"jdbc:firebirdsql://localhost:3050/C:/firebird/database/EMPLOYEE.FDB"
Your URL is most likely broken for this driver.
Attach actual source to the jar and set a breakpoint in FBDataSource.getConnection(...) and see what values are actually present when the connection is attempted made.
Are you absolutely certain that the combination of a hostname with port agrees with a path to the FDB-file?
Looking at the documentation on this site:
http://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html, item 3.1
It seems that after the [port], you must have an slash "/" or double slash "//" in case you would connect on a linux server.
To connect to the database located on remote machine or cloud (linux) then use following link.
jdbc:firebirdsql:34.212.208.251/3050:/opt/app/db/sample_training.fdb
You should try this one. It works for me on Windows.
jdbc:firebirdsql://localhost:3050/C:\firebird\database\EMPLOYEE.FDB
Also make sure you added an exception for port 3050 to the Firewall.
Connection string example for Apache Tomcat properties.xml with specified IP, port, data base alias and encoding:
<entry key="db.url">jdbc:firebirdsql:127.0.0.1/2222:my-db-alias?lc_ctype=WIN1251</entry>

Categories