Iam trying to connect my app to the MySQL Back on my OpenShift Account via jdbc. Here my source:
Class.forName("com.mysql.jdbc.Driver");
Connection m_connection = DriverManager.getConnection(url , user , pass);
i´ve added my jdbc_connector.jar to the build path, but if im testing it on localhost or in web i always get an
'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver'
How to solve the problem, where to add the jdbc_connector.jar?
Thanks.
JBDC need you to have a path to the jar for the server you are using in path...
Soooo...
Do not forget to add the path of the connector to the classpath. If the connector name is
mysql-connector-java-5.1.21-bin.jar stored in C:\mysql-connector-java-5.1.21, then
add c:\ mysql-connector-java-5.1.21\mysql-connector-java-5.1.21-bin.jar to the
classpath.
Oh and here is the connector http://dev.mysql.com/downloads/connector/j/
Related
I`m trying to connect to my PostgreSQL database. What I create a connection and click the button "Test", I receive an error message. I can connect to this db via pgadmin without any problems, so it is not a connection or credentials issue
I`m using Pentaho kettle 8.3, Windows, java version "1.8.0_231"
Error connecting to database [Name] :org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database
Error connecting to database: (using class org.postgresql.Driver)
Ошибка при попытке подсоединения.
Full error stack: https://pastebin.com/cLiB288e
Try to add postgresql-42.1.1.jar in the /lib folder of PDI, restart the spoon and try again.
i faced 2 issues myself connecting to PostgreSQL few months back and following 2 things helped me
1.add postgres-42.1.1jar file in the 'lib' folder under PDI and restart the spoon.
if the normal JDBC connection convention does not work for you try below tip
while configuring the connection specify host name as follows
{HOST IP}:{HOST PORT}/{instance name}?
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 am setting up a test GlassFish Server to learn NetBeans, Java, GlassFish web application development. I was able to do a basic deployment successfully and am moving on to databases.
I am trying to set up a MS SQL Server connection pool in the GlassFish admin. After configuring the datasource as javax.sql.Datasource and setting the properties, it fails to successfully ping the connection.
When I try to ping the connection, I get this error
Ping Connection Pool failed for SQLDB. Class name is wrong or classpath is not set for :
com.microsoft.sqlserver.jdbc.SQLServerDataSource
It looks like the .jar file isn't being loaded. I have placed the sqljdbc4.jar in the glassfish\modules folder.
What is the correct process for setting up a JDBC connection pool for SQL Server?
In case you are using JRE 7 : use JDBC41
in case you are using JRE 8 : use JDBC42
Unzip the exe from the following link : https://www.microsoft.com/en-us/download/confirmation.aspx?id=54671
Paste the jar in the lib folder of glassfish .
Once done define property under connection pool as URL and pass full qualified connection name as : jdbc:sqlserver://localhost\MSSQLSERVER:1433;databasename=AdventureWorks2016;integratedSecurity=true
Edited: I checked the log file, and the URL message is:
Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'postgresql://adminxxxxxxx:xxxxxxxxx#10.1o.1o.10:5432'
I get the following error with postgres on openshift (9.x)
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getDriver(DriverManager.java:278)
My URL is ${OPENSHIFT_POSTGRESQL_DB_URL}
This exact build works on my local host (different URL, of course), and I can see the openshift jar in the correct place in the war file
Any ideas?
Turns out the URL in the environment variable on Openshift does not work.
See here:
http://mikeski.net/blog/index.php?/archives/17-Postgres-and-JBoss-on-openshift.html
Iam new on using NetBeans 7.4 , i want to connect my java application to MYSQL , the application is desktop application .
i have already install MYSQL workbench 5.2 and create database with one table .
from NetBeans services on Databases i register MYSQL server , i enter these values :
localhost : 127.0.0.1 , user : root and password : root.
NetBeans ask me to set MYSQL command Path (Path to start command) i insert this path :
C:\Program Files\MySQL\Connector ODBC 5.1\myodbc-installer.exe
from main class in java i saw from net how to set connection :
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/sameer", "root","root");
System.out.println("Connected database successfully...");
} catch (Exception e) {
System.out.println(e);
}
but all time the exception will execute :
java.sql.SQLException: No suitable driver found for jdbc:mysql://127.0.0.1:3306/sameer
You need to include the mysql connector jar in your project.
If you haven't downloaded it yet you can find it here http://dev.mysql.com/downloads/connector/j/
Once you have downloaded it:
right click on the project
select Properties
select Libraries -> Add JAR/Folder
navigate your file system to select the jar you previously downloaded
save and it will run correctly