I am using play framework and I want to connect db, but I can't because I am getting following error:
play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]]
Caused by: play.api.Configuration$$anon$1: Configuration error[Failed to initialize pool: Unknown system variable 'tx_isolation']
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Unknown system variable 'tx_isolation' java.sql.SQLException: Unknown system variable 'tx_isolation
I tried to find tx_isolation, but it doesn't exist:
mysql> show variables like 'tx_isolation';
Empty set (0.00 sec)
So what is and how can I find tx_isolation?
Sorry. this is my error code. and I use mysql 8.0.11. so i find 'transaction_isolation'
play.db {
config = "db"
default = "default"
}
db {
//TODO : 작업필요
default.driver = com.mysql.jdbc.Driver
default.url = "jdbc:mysql://127.0.0.1:3306/testPlayDB"
default.username = root
default.password = "321A#654"
}
Error cause Default.url = "jdbc:mysql://127.0.0.1:3306/testPlayDB"
i use Scala, playframework and StackOverflow first time...
Thank you.
If you are using MYSQL8, try to show variables like 'transaction_isolation'.
Mysql8 has renamed tx_isolation to transaction_isolation.
I had a same problem. I upgraded my MySql Connector and solved my issue. try to use version 8 , like this:
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
You have a mismatch between client lib version and server version.
Here are the version numbers where things change:
mysql-connector-java-8.0.8 release notes
Important Change: Following the changes in MySQL Server 8.0.3, the system variables tx_isolation and tx_read_only have been replaced with transaction_isolation and transaction_read_only in the code of Connector/J. Users should update Connector/J to this latest release in order to connect to MySQL 8.0.3. They should also make the same adjustments to their own applications if they use the old variables in their codes. (Bug #26440544)
mysql server 5.7.20 release notes
Previously, the --transaction-isolation and --transaction-read-only server startup options corresponded to the tx_isolation and tx_read_only system variables. For better name correspondence between startup option and system variable names, transaction_isolation and transaction_read_only have been created as aliases for tx_isolation and tx_read_only. The tx_isolation and tx_read_only variables are now deprecated and will be removed in MySQL 8.0. Applications should be adjusted to use transaction_isolation and transaction_read_only instead.
mysql server 8.0.3 release notes
The deprecated tx_isolation and tx_read_only system variables have been removed. Use transaction_isolation and transaction_read_only instead.
I was also getting the same error (when I am using the mysql6 database in mysql5 it was working fine) then I changed my connector jar from mysql-connector-java-5.1.46.jar to mysql.jar then the problem gone.
Related
My Solr 8.10.1 data-importhandler indexer is throwing error when trying to import from MySQL5.7.
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because "this.serverVariables" is null
I was alarmed by the occurence of jdbc4 in there.
My environment variables:
JAVA_HOME: C:\Program Files\Java\jdk-17.0.1
PATH: C:\Program Files\Java\jdk-17.0.1\bin;C:\Program Files (x86)\Java\jre1.8.0_311\bin
I have jdbc9 in my solr folder:
\solr-8.10.1\dist\mssql-jdbc-9.4.0.jre8.jar
So I searched my entire drive for jdbc and found just 1 occurrence of jdbc4 in D:\solr431_DELETEME\example\lib\sqljdbc4.jar, which I've also deleted, but the error above keeps occurring.
data-config.xml
<dataSource type="JdbcDataSource" name="ds-wordpress" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/wpmydb" user="<myuser>" password="<mypwd>" />
My configuration does work on my local machine, so it MUST be a setting on the server, I just don't know what it is.
I already checked here: MySQLNonTransientConnectionException Could not create connection to database server. Caused by: java.lang.NullPointerException
And tried this URL too, but to no avail: url="jdbc:mysql://localhost:3306/wpmydb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT"
What else can I try?
First :
Check if you have JDBC driver available in your solr. If not you can download and copy in dist folder or lib folder in solr and map that path in solrconfig.xml file.
Second :
If you are sure the first step is not an issue in your case then try to uninstall different versions of java you have and install a single version for your JDK and JRE.
Third :
If first and second both not working, then it might be the issue with your username password or maybe you are using VPN to access your server which you forget to use this time.
In our Java project we have already connected two DB's to fetch data using two connection pools.
But now one of our DB is upgraded to PostgreSQL 12 and the other DB has the old PostgreSQL 8 version.
We have imported "postgresql-42.2.11.jar" in the project, Can this jar connect both versions or should we import the old "postgresql-8.1-407.jdbc3.jar" too. If so, will we get any error for using two PostgreSQL jars.
But the surprise is, The project works in local system perfectly connecting two versions of DB with one jar ("postgresql-42.2.11.jar"), Just throwing an warning "WARNING [http-nio-8084-exec-55] org.postgresql.jdbc.PgConnection. Unsupported Server Version: 8.1.11",
But after making it live in linux server its not working, it throws an abrupt error as "Exception org.postgresql.util.PSQLException: FATAL: invalid value for parameter "TimeZone": "Asia/Kolkata"".
It looks to me like the 'Kolkata' spelling was not added until June 2008, first appearing in v8.1.12, one minor version newer than you are using.
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'
I thought the Type 4 JDBC driver was pure Java and wouldn't require native libraries.
When I put db2jcc4.jar in the WEB-INF/lib directory of my Tomcat app packaged as a .war file, I get the following error when attempting to use the app: Got SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.12.55] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError
The relevant application code is as follows and the exception is thrown due to the last line in the listing:
import com.ibm.db2.jcc.DB2SimpleDataSource;
// ...
DB2SimpleDataSource main_db2_data_source = new DB2SimpleDataSource();
main_db2_data_source.setUser(main_database_user);
main_db2_data_source.setPassword(main_database_password);
main_db2_data_source.setServerName(main_database_host);
try {
Integer main_database_port_integer = Integer.parseInt(main_database_port);
main_db2_data_source.setPortNumber(main_database_port_integer);
} catch (NumberFormatException exception) {
throw new WebException("...");
}
Connection main_connection = null;
try {
main_connection = main_db2_data_source.getConnection();
I suspect the problem is that you haven't told it to use the type 4 driver - the same jar file contains both type 4 and type 2 drivers, I believe.
Try:
main_db2_data_source.setDriverType(4);
The db2 driver needs another jar that includes the license.
This license controls the connection type. If you are going to use "db2 connect" to connect to a mainframe as an i series you should use the corresponding license. If you are going to connect to a Linux UNIX or Windows server, the license is included when you get the "Data server client for JDBC"
Also try this:
Goto Configure Build Path --> Libraries
--> JRE System Libraries
--> Native Library Location : Set this to %DB2HOME%/BIN
(which is where db2jcct2.dll is saved)
Recently i have faced this issue, when i was connecting to DB2 from Glassfish server. for this i have followed below steps and resolved this issue.
Please check it the below steps
step1) i have checked DB2 details in Domain.xml file.there i have seen only
username,pwd,databaseName,serverName ,portnumber, But i havent see DriverType.
Means Type of driver is 2 or 4.
2)for adding Type of driver i have logged into the Glassfish server admin console
Resources-->JDBC-->Connection pool -->our poolname --.add extra property
here i haved added as drivertype is 4.
Hence my problem has been solved
Thanks,
Ramaiah Pillala.
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>