No suitable driver found for jdbc:postgresql://localhost:5432/postgres - java

I tried several tutorials that I could get my hands on, but all of them lead to the same error:
18:28:24,583 INFO [stdout] (default task-1) Database error :No suitable driver found for JDBC:postgresql://localhost:5432/postgres
I have configured the connection following this tutorial: HOW TO SETUP POSTGRESQL DATASOURCE WITH WILDFLY
and tried several ways to fix the problem. I have tried both the management console and the configuration file. The most common solution was trying to add the postgresql-42.2.24.jar to the project structures in modules, but that doesn't solve it. I have created a new simple Java project where I am just trying to connect to the database and it works (I used the same credentials in both places), but when I'm trying to link the server with the DB it's like it doesn't see the driver... When adding a Datasource from Intellij it works perfectly fine (it sees the tables, I can run queries and everything), but I can't get the connection with the server to work.
I'm using Wildfly 24.0.1 Final and Java 8.

Change JDBC to jdbc, it's case-sensitive.

Related

Jhipster projects keep trying to use wrong database

I'm trying to develop some test projets using jhipster but I'm facing a problem.
I've choosen to use H2 in memory in develop mode and postgresql for production.
When I start the project in dev mode, it looks for postgres db and also for a db with the wrong name.
Also, every single project looks for the same db, but I can't find the properties with that db name.
I tried a projects using postgres also in dev mode and it works, but using always that database!
I tried to debug every single row but I couldn't find where the code find that url.
I found out that it sets it in DataSourceBuilder url.
Do you have any ideas?
Thank you
I solved my problem.
I had set some spring datasource configurations in my Windows environment variables.
That's why each project ignored its own properties.

Connect to a DB2 with JDBC from domino

I am trying to connect to a db2 database from my domino application without using the extension library.
I have created a managed bean that it only connects to the db2 and prints a message on the console.
I call the method of the managed bean from a button on an xpage.
The code in the bean is this:
Class.forName("com.ibm.db2.jcc.DB2Driver");
String url = "jdbc:db2://10.0.1.49:50000/AVIN";
String user = "db2admin";
String password = "ibmdb2";
con = DriverManager.getConnection(url, user, password);
System.out.println("Successful TEST JDBC Connection!!");
I have also configured my build path and added the db2jcc.jar library.
The problem is that i am getting
java.lang.ClassNotFoundException for com.ibm.db2.jcc.DB2Driver
Why is this happening?
Is the DB2 JDBC driver available to your application? I suspect not.
You may need to package the driver in a plugin - within the NSF it will probably hit Java security issues and not work. More recent versions of the Extension Library (the Designer update site install) provide a menu option to Domino Designer to allow you to easily package up a JDBC driver as a plugin, which can then be deployed to your Update Site database.
I strongly recommend using the Extension Library. It will provide robust connection pooling amongst other things. Without it, you may well hit problems already considered and resolved by the experience of the Extension Library developers. If you do hit problems, you may struggle to find anyone with the experience to help you.

mysql-connector-java-5.1.23-bin.jar NOT deployed

I am coding my first web app in java and got stuck in db stuff. Followed two tutorials (ref: https://netbeans.org/kb/docs/web/mysql-webapp.html and part1:http://www.javaguicodexample.com/javawebmysqljspjstljsf5.html part2: http://www.javaguicodexample.com/javawebmysqljspjstljsf5_1.html) and got the same issue regarding db config. Crosschecked multiple times and found that mysql-connector-java-5.1.23-bin.jar is there in the desired path and configured properly but is not deployed on running the app. Due to this getting TABLE/VIEW not found.
Kindly help as I am debugging by crosschecking the steps of the provided manuals but its not sufficient.
If you are receiving "TABLE/VIEW not found" that means application is successful in making database connection. There is no such table/view exists in the database.
Regarding dependencies, I would suggest to use some build tool like maven or gradle to make sure all dependencies and versions are managed properly

jdbc connection error: not associated with a managed connection

My application is trowing the following exception:
java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6#4fe91321
This is happening in production I'm not able to get this problem in development and for that I'm not able to solve it.
The root of the exception is code line dbConn.prepareStatement(sql);
From what I was able to find in the web, the cause for this can be:
Over jdbc connection, a jboss connection is wrapped but the wrapper is empty. The original jdbc connection inside is no longer there.
JDBC Connection is already closed and trying to work with close connection is the reason why I'm getting this exception.
The transaction manger detects transaction that is taking to long then the transaction timeout.
So if someone can point me what is the problem because I'm not able to get this problem in mine development environment.
Also what logs can I add that will help me detect the problem in production - I'm using Java, JBoss, Postgre.
I'have enable connection close monitoringa, and also to add is that the issue is not consistent
I just resolved the issue.
It's my jndi driver not compatible with the latest java frameworks.
I'm using Oracle db and ojdbc6, and i download a latest ojdbc6 from maven repository and replace the old same name jar file. It works like bird now.
If you are using an EJB, it's possible that your Stateless Session Bean Pool is not big enough. The connection can't find an associated thread.
Maybe you have an extended Transaction for a not Stateful Session Bean, wich is maybe not a good idea.

JavaMelody on Railo: no SQL statistics?

I just added JavaMelody to my Railo Application server but I can't get SQL statistics.
I followed this excellent post: http://aarongreenlee.com/share/monitor-tomcat-performance-with-open-source-software
Maybe problem can be exported to other AS than Railo.
Did you try the instructions here on configuring JDBC monitoring here: http://code.google.com/p/javamelody/wiki/UserGuide#7._JDBC
It looks like it uses a JDBC proxy if you're not using datasources in JNDI. I've recently had cause to look at how Railo does datasources and it doesn't do JNDI, so you'll probably have to set up a new datasource and follow the instructions. Do let me know whether it works.
[UPDATE] Just tried it myself. Whilst I can get the datasource working, I still get no stats. Looks like we may be running into this error:
http://code.google.com/p/javamelody/issues/detail?id=142

Categories