Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all 884 articles
Browse latest View live

MySQL Connector/J loadbalance feature not working when user credentials changed (1 reply)

$
0
0
I am using the MySQL Connector/J loadbalance feature with two MySQL databases. The requirement here is to recycle data on each database one by one to achieve zero downtime. So weekly or monthly data on each database will be recycled.

First approach
The first approach we took is by changing the port of each instance to recycle the data

Stopped mysql instace(localhost:3306)
Changed the port
Started mysql instance
Recycled the data
Stopped mysql instance
Changed the port back to 3306 as per jdbc loadbalance URL
Started mysql intance back
Repeated Steps 1- 7 for mysql intance 3307
This is working like a charm however we are restricted to use this approach.

Second approach
Second approach is to change the user credentials of each database one by one.

removed user abcd mysql instace(localhost:3306)
Restart service mysql instace(localhost:3306)
Recycled the data with some other user credentials
Added user user: abcd password: abcd back
Restart service mysql instace(localhost:3306)
This approach is not working and non of the queries are being executed after changing the credentials and restarting the service. None of the queries are executed.

Do I need to add some more parameters as per MySQL reference https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html?

Is there any other way I can achieve Zero downtime without changing the port and using loadbalance feature of JDBC?

Cannot connect jboss to mysql 8 cluster with mysqlrouter (no replies)

$
0
0
I am fairly new to JBOSS and mysql router, so bear with me. We have a working stable install of JBOSS EAP 7.0 on a Windows 2012 R2 server running custom web services software. We have a new instance of mysql 8 InnoDB cluster (3 nodes) running on RHEL 7 that I need to connect to from the JBOSS server.

I have installed mysqlrouter on Windows and successfully bootstrapped it and installed it to run as a service. The log shows that it is connecting to the cluster with no errors.

I have installed the Connector/J software and registered the driver as a core module and then built a jboss datasource using the mysql driver class.

When I test the datasource connection, I get an error stating the connection is not valid. In the JBOSS server.log I get
java.sql.SQLException: Access denied for user 'username@192.168.27.16' (using password: YES)

Based on the logs, it appears there is no connection issue between JBOSS, mysqlrouter, and the mysql cluster.

I have verified that the username and password in the datasource definition (not shown here) are valid and work on the database.

I know the mysql cluster requires secure connections. That is indicated in the mysqlrouter.conf file and I have verified that we have a valid certificate and CA certificates installed on our JBOSS instance. These are being used for other connections. Is there something else that needs to be installed or registered with mysqlrouter in terms of certificates?

I am stumped on what to check next. Any suggestions would be helpful.

How to specify property IGNORE_SPACE in URL (no replies)

$
0
0
Hi

I am using Powerbuilder as frontend and mysql as backend and trying to connect using JDBC driver. I sucessfully connected to mysql but it gives error and to fix this error I need to specify option IGNORE_SPACE. Please help me I tried following but didnt work out.

SQLCA.DBMS = "JDBC"
SQLCA.LogPass = "pass123"
SQLCA.LogId = "root"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Driver='com.mysql.jdbc.Driver',URL='jdbc:mysql://localhost:3306/mydb&SQL_MODE=IGNORE_SPACE'"


Kindly help me with the url

useCursorFetch=true impacts getFloat() values. (no replies)

$
0
0
I encountered a strange JDBC case when I use float values with the connection property useCursorFetch. Setting useCursorFetch to true/false makes getFloat() returning different values with different precision.

Reproduce:
1. Create a table:

CREATE TABLE data_type(
col_float float
);

2. Insert data: (I know float is a single precision type, but in our case, double values are inserted)

INSERT INTO data_type(col_float) VALUES(358294.648941);
INSERT INTO data_type(col_float) VALUES(120263.815023);

3. JAVA code:

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useCursorFetch=false", "user", "password");
PreparedStatement statement = con.prepareStatement("select col_float from data_type;");

System.out.println("Executing query...");
ResultSet rs = statement.executeQuery();
while (rs.next()) {
System.out.println(rs.getDouble(1) );
}

rs.close();
statement.close();
con.close();

When useCursorFetch=false, I got the following output in the console:
358295.0
120264.0

But when I set useCursorFetch=true, I got different values in the console:
358294.66
120263.81


Could somebody please explain why useCursorFetch impacts the values?

Thank you very much.

Fractional Seconds Support with Connector/J and MariaDB (no replies)

$
0
0
Hi,

Sorry if this is not the right place.

I am using Connector/J 8.0.12 to connect to a MariaDB 10.3.

We are unable to insert timestamps with fractional seconds into the database into a DateTime(6) field.

The reason is, that the code to determine the capability of fractional second support (in the class com.mysql.cj.protocol.a.NativeCapabilities) checks for the version to be greater 5.6.4. But MariaDB provides the version String "5.5.5-10.3.10-MariaDB". MariaDB in Version 10 is capable of fractional seconds.

Can you provide some help please?

with kind regards
Alex

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) (no replies)

$
0
0
I can't make the connection between my java application and Mysql 8.

I didn't change anything in my java program and the connection worked perfectly with Mysql 5 version.

I was using user : "root" and password "root" like always did. The connection between java app and MySQL 8 failed for this user. But was ok between Mysql 5.x and java.

I created another user with another password and the connection between java app and Mysql 8 failed again.

When I enter Mysql via Toad framework using the above two users and passwords, I could make the connection without any problem.

But not with my java application, from where I received the message : "MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) "

The same message for the second user I created.

The connector/J was mysql-connector-java-8.0.13.jar

Could anyone tell what has been the problem ?

Thanks

Java 11 modules (no replies)

$
0
0
Are there any plans to issue a version of Connector/J that complies with the Java 11 module system. I would need this to be able to use the Java jlink tool to include Connector/J with my application.

Inconsistent Data Truncation Errors using v5.1.28 (no replies)

$
0
0
I've got a table with a column defined as VARCHAR(100). I've received 1406 errors on values that are under 100 characters - some 20 characters, others 83 characters. But values with these lengths don't always fail.

I've been doing some searching to see if there are any issues like this with the version of the connector we're using, but haven't as yet found anything.

If anyone has thoughts on this, I'd really appreciate it.

TIA,

Les

Problem in connecting to MYSQL (no replies)

$
0
0
I have problem in fixing the String URL for connecting to MYSQL and I need help in the syntax.

MYSQL verion : 8.0.12
OS : Windows 10

Here's the error I am receiving :

Caused by: com.mysql.cj.exceptions.UnableToConnectException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ';serverTimezone=UTC&useSSL=False'.

Here's my String URL ;


public static final String URL ="jdbc:mysql://localhost/project?autoReconnect=true&ampserverTimezone=UTC&useSSL=False";

I have tried many ways but even if I added a ; near to &amp it will still gives me the same error.

It has been going like this for more than 1 week.

Hope someone can help me or offer me an alternative to do the connection.

Tks.

Incorrect string value: '\xAC\xED\x00\x05sr...' for column (3 replies)

$
0
0
I got this error which I need help to resovle.

java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'subjectName' at row 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:975)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1114)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1062)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1383)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1047)

I have also checked the problem column Name : subjectName is in utf8mb4

What I have attempted so far:
-----------------------------
I have added my.cnf

[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

And re-start server but to no avail.

I am using MYSQL 8.0.12 in Windows 10, running a Maven web App in Java EE with CDI.

Eclipse Oxygen.

Please help.

Use MySql Update Lock or Java Thread-Safe??? (no replies)

$
0
0
PROBLEM STATEMENT:
I have tables that can be read or updated by several different Java apps.
*** During updating, my other apps must be able to generate reports from same tables using old data (a dirty read);
*** Also, it is possible that another user may want to update the same tables using same app, I don't want a race. I want them updated in the order that the transactions are uploaded to the cloud.


QUESTIONS:
Should I be using a mySQL SELECT...FOR SHARE, and if I use ...FOR SHARE, then in the Java code, do I still need a thread-safe environment???
For example, I am now using an ArrayList, I might need to modify code to using a Vector.
I don't want to change codes if at all possible.

THANKS for sharing.

How do I set the timezone in MYSQL 8.0.12 or configure the JDBC driver?? (no replies)

$
0
0
I tried to test out the MYSQL Connection after a failed insertion of code, even though the code is correct cos it was inserted using the same exact method.

Last time, I was using a lower MYSQL version and had no problem with the timeZone and connectivity issue.

So, now the test Connection via Eclipse data explorer gave me an error message :

Could not connect to New MySQL.
Error creating SQL Model Connection connection to New MySQL. (Error: The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)

The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

Error creating JDBC Connection connection to New MySQL. (Error: The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)

The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.


Here's the setting the code for MYSQL connection:

public static final String URL ="jdbc:mysql://localhost/project?autoReconnect=true&serverTimezone=UTC&useSSL=False&allowPublicKeyRetrieval=true";


I have put in the correct MYSQL Connection driver :
mysqlconnector-java-driver-8.0.12.jar

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061) (no replies)

$
0
0
I hope someone can tell me how to resolve the above error.

After I have added

[mysqld]
default-time-zone = 'UTC'

in my.ini file in MYSQL 8.0 workbench, I am losing the connection on localhost.

I am running MYSQL version 8.0.12 on windows 10.

Does MYSQL 8.0.13 works with Eclipse IDE? (no replies)

$
0
0
I would like to know if MYSQL 8 works with Eclipse IDE, specifically Eclipse Oxygen.

Cos I have done some insertion and using the same old codes but the insertion is not successful, even though there was no logging error whatsoever.

Eclipse Oxygen only has 5.1 MYSQL connectivity driver as it's latest and I am not sure if overwriting the connectivity driver works or not cos this was I have done but insertion did not work.

How do I create my table to avoid java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '' for key 'PRIMARY' (no replies)

$
0
0
I would like to know how should I create my table such that the below error will not occur ;

java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '' for key 'PRIMARY'

Currently, I have

CREATE TABLE tutor_subject(

tutor_id INT NOT NULL,
subjectName Varchar(50) NOT NULL,

PRIMARY KEY (tutor_id))Engine=InnoDB Default charset=utf8mb4

Is it alright not to have Primary Key at all?

Any recommendation for indepth JavaFX books ? (no replies)

$
0
0
I need to render mySQL resultsets in graph using JavaFX.
My sql and analytics work fine, just need a good book on how-to using JavaFX

Problem with inserting IP Addresses into mySQL (1 reply)

$
0
0
I am creating an IPAddress Vault for my apps, each of which is asssigned to some specific piece of h/w.
Ideally the range should be from 192.168.100.mmm all the way to 192.168.900.nnn
So, this is a snippet:

START TRANSACTION;
DROP TABLE IF EXISTS TestIP;
CREATE TABLE TestIP (IPAddress INT UNSIGNED
    , TestBy_ID INT NOT NULL
    , InsertDateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    , PRIMARY KEY (IPAddress)
)   ENGINE=INNODB AUTO_INCREMENT= 10 CHARACTER SET utf8 COLLATE utf8_general_ci;
INSERT INTO TestIP(IPAddress
	, TestBy_ID
	, InsertDateTime)
VALUES(inet_aton('192.168.600.10'), 12345, default);
SELECT inet_ntoa(IPAddress), TestBy_ID, InsertDateTime FROM TestIP
COMMIT;

mySQL workbench cannot insert address range bigger than 192.168.250.mmm, throws following error:
Incorrect string value: ''192.168.260.10'' for function inet_aton, but okay for 192.168.250.10
Weird!

Need solution for MySQL Not connected problem (no replies)

$
0
0
Actually I have trouble with MYSQL database.

I am working in below mentioned working Enviroment.

1.CentOS Linux release 7.6.1810 (Core)

2.Tomcat 7

3.JAVA 1.8.0_191 - (openjdk version)

4.MySQL Databse - Ver 14.14 Distrib 5.6.42

I have developed the one Java Web Application using tomcat and MySQL database.

From Eclipse IDE , I run code MySQL Is connected successfully and It's working Perfectly.

But After creating the war file and I deployed that war file in Tomcat Server ,

MySQL Database Not Connected. I am getting following Exception.

In My Application , I am writing Log file for exception. that Log file shows this Exception.

Kindly provide the solution as soon as possible.


1.0-20160813-CMS:08-Jan-2019 11:33:03 PM : com.mysql.jdbc.CommunicationsException --> DbUtil : getConnection
com.mysql.jdbc.Connection.createNewIO(Connection.java:2820)com.mysql.jdbc.Connection.<init>(Connection.java:1553)com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)java.sql.DriverManager.getConnection(DriverManager.java:664)java.sql.DriverManager.getConnection(DriverManager.java:247)com.sardonyx.dbaccess.DbUtil.getConnection(DbUtil.java:19)com.sardonyx.dbaccess.DataAccess.callquery(DataAccess.java:5651)com.sardonyx.dbaccess.DataAccess.querytoInt(DataAccess.java:1385)com.sardonyx.dbaccess.DataAccess.getStringResourceModule(DataAccess.java:1365)com.sardonyx.server.CommonServlet.doPost(CommonServlet.java:197)javax.servlet.http.HttpServlet.service(HttpServlet.java:650)javax.servlet.http.HttpServlet.service(HttpServlet.java:731)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748)

Incorrect string value: '\\xF0\\x9F\\x91\\x8F\\xF0\\x9F...' (1 reply)

$
0
0
After updating from MySQL Connector/J 5.1.47 to 8.0.13, my service is sporadically getting into a state where any attempts of inserting Unicode values gives errors along the lines of:

Incorrect string value: '\\xF0\\x9F\\x91\\x8F\\xF0\\x9F...'

My database, table and columns are all set to utf8mb4. Historically I have not included any character encoding options in the URL, but I have tried including characterEncoding=UTF-8 and it did not help. My server is currently running with the following settings:

character_set_client: utf8mb4
character_set_database: utf8mb4
character_set_results: utf8mb4
character_set_connection: utf8mb4
collation_connection: utf8mb4_bin
collation_server: utf8mb4_bin
character_set_server: utf8mb4

I never had any issues on Connector/J 5.1.47. The trouble started after upgrading to 8.0.13. Is this a known problem? How can I further debug it?

JDBC For MySQL 8/MySQL 8 Problem (no replies)

$
0
0
I already migrated to:

mysql Ver 8.0.13-commercial for Linux on x86_64 (MySQL Enterprise Server - Commercial)

But right now I am encoutering a big problem when at first boot/server initialization, I cannot login to MYSQL 8.0 using the latest JDBC Connector:

mysql-connector-java-8.0.13.jar

At first, the Java application cannot login to MySQL with ERROR:


$ java TL_TERMLIB
ERR e=java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

But when I try just the MySQL client (command line) using this simple command:

$ mysql -ucoreadm -pcoreamm

then quit to the shell to execute again the command:

$ java TL_TERMLIB

The application is now connected to MySQL. I have tested this a couple of times already and the same result.

I hope someone helps. Thanks!

The video URL: https://www.dropbox.com/s/0exuial4iowk6bz/MySQL8-Using-JDBC-2019-01-19_18-22-41.mp4?dl=0

Regards,
Viewing all 884 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>