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

java connector/J5.1 mysql (no replies)

$
0
0
I am working on the connection of MySQL with Java.
I understand this is a tested practise because I see many file applications about it.

I have obtained the files:
LoadDriver.class
MakeConnection.class
below from the Connnector J 5.1 documentation.
The files are pasted in the jdk1.8.0_71 /bin directory en succesfully compiled into *.java files.

The mysql-connector-java-5.1.44-bin.jar file from the ConnectorJ5.1 documentation was also pasted in the jdk1.8.0_71 /bin directory.

The first file is the driver loader.
The second file is de connection maker


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

// Notice, do not import com.mysql.jdbc.*
// or you will have problems!

public class LoadDriver {
public static void main(String[] args) {
try {
// The newInstance() call is a work around for some
// broken Java implementations

Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
}
}



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MakeConnection {
public static void main(String[] args) {

Connection conn = null;


try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/" + "user=shorty@localhost&password=asdfgh456");
// Do something with the Connection
System.out.println("Connected to database");

} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}

}
}


SQLExeption: No suitable driver found for jdbc:mysql://localhost:3306/user=shorty@localhost&password=asdfgh456
SQLstate: 00001
VenderError: 0

This error above shows.
The files were entered at the commandline, with administrator privelige.
shorty@localhost&password=asdfgh456 is a tested user with password.

I hope you can point out the mistake I make, or any syntax error.

Hope to behearing from you soon.
Signing, best regards,
W.M.de Korte
info@wikowebsites.nl

Loading data into mysql tables taking insanely long time (no replies)

$
0
0
I'm a Java developer with some functional knowledge of mysql (not an expert by any means!). I have mysql version 5.7.21 which is hosted on Ubuntu 16.04.3 LTS (xenial).

I have a Java program which uses dbUnit frameworkm which downloads the data from our production servers into xml files and tries to load them into mysql tables. In fact, this process actually recreates the schemas and tables in local mysql, before loading the data into the tables. This process used to take around 40-45 mins earlier, whereas all of a sudden it started taking insanely long times, i.e., multiple days. Does anybody have any insights in to this problem? I'm not sure what kind of data helps in troubleshooting this issue, but will provide it upon demand.

Thanks in advance,
Purna

rewriteBatchedStatements / SQL injection (no replies)

$
0
0
We are using a Google CloudSQL MySQL instance with the MySQL Connector/J and Spring Data on top.

We notice some performance issues when inserting large amounts of data. Setting rewriteBatchedStatements=true improves performance dramatically. But the documentation says:

> Notice that this has the potential for SQL injection if using plain java.sql.Statements and your code doesn't sanitize input correctly.

What does that mean exactly? Can you give an exmaple how such an SQL injection could be accomplished and prevented?

Thanks.

Java Socket Jdbc mysql connection (no replies)

$
0
0
I am have my own java socket server. in this socket more than 10,000 users connected at a time. i want update some user details in to database. I use jdbc for mysql connection. i face lots of pblm when multi user connect with mysql i face the error, operation not allowed after statement is closed, and resultset is closed, connection is closed. i dont know how to handle the mysql connection for each user. please help us. I need your guidence, Thank you.

Unable to connect using Connector JDBC (no replies)

$
0
0
I am unable to connect to a MySql server database on another local Intranet machine. I have installed the connector both under Windows and Linux. In neither case am I able to connect using the MySQL Workbench program or the more generalized SQL Workbench program. In both cases the error I receive is:

"Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."

The SQL server and database are on port 3306 on a local intranet IP address such as 192.168.nnn.nnn. I can use Putty successfully either on Windows and Linux using the intranet IP address to logon to the machine from a different computer on my intranet. I can type in the intranet 192.168.nnn.nnn address in my browser to go to a web server setup on the machine from a different computer on my intranet. Finally using the web PHPAdmin program I can type in my browser http://192.168.nnn.nnn/phpmyadmin to open a PHP admin page which lets me enter my MySQL username and password to access my databases on the MySql server successfully.

My thought that it must have something to to with the JDBC connector but I do not know what the problem is. The connector I am using is 5.1.42 and I am running Java 1.8.0.161. The MySql server I am trying to connect to is on a Debian Linux ARM system.

Does anybody have any ideas why the connector is failing to connect to the remote MySQL server on my local intranet, whereas direct connections to the IP address via Putty and my web browser ( Firefox ) succeed without any problem ?

"Broken Pipe" in JDBC due session autorefresh (no replies)

$
0
0
Hi!
I have a Tomcat application with two database connecctions: JDBC and Hibernate ones. The Hibernate connection fails after 20 hours of inactivity due c3po session auto-refresh (free memory: 213412744 at that moment). Here is a stack trace:

at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2652)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80)
... 44 more


Could you help me with that? Hibernate forim said that it is clearly MySQL case. I have tryed to use DataSource and several sets of c3po properties with no effect. Help me please?

A Problem of Accessing MySQL via JDBC using Pipe (no replies)

$
0
0
1. Whether JDBC can access MySQL using pipe under Linux
2. I tested retrieving 5 million rows of data under win10 using the same Java code in different URLs, the result is named pipe is 30-50% slower than tcp. The document says it is related with the system configuration. So I want to know the specific configurations that could affect the result and how?
3. How do the values of socketFactory - com.mysql.jdbc.NamedPipeSocketFactory and com.mysql.jdbc.StandardSocketFactory – in jdbc url work? And how would they affect the retrieval efficiency?

Alternative mySQL paths (no replies)

$
0
0
I have MySQL installed on two physical paths. I want to switch among those. Is there any way to do that in Ubuntu 16.04.

ArrayIndexOutOfBoundsException at com.mysql.cj.mysqla.io.Buffer#readInteger (no replies)

$
0
0
I'm using mysql-connector-java-6.0.6.jar to connect mysql server, both 5.7.21 and MariaDB-10.1.22.
Eanble useServerPrepStmts, then execute a normal preparedStatement query, such as:

"select f1 from xxx"

The column f1 type is text/longtext, get the value with ResultSet.getString(1), if f1 has value, get the right value, however if f1 is null, it throw an exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.mysql.cj.mysqla.io.Buffer.readInteger(Buffer.java:288)
at com.mysql.cj.mysqla.result.BinaryBufferRow.getValue(BinaryBufferRow.java:231)
at com.mysql.cj.jdbc.result.ResultSetImpl.getString(ResultSetImpl.java:880)

While getObject(1) return null, because it check the null value first(call getNull).

I want use the specific type method, so I chose change the Buffer.readInteger method to avoid the error, check byteBuffer's length:

if (this.byteBuffer.length == position) {
return 0;
}

Is there some official suggestions to avoid this problem?
Thanks.

How to disable the field cache in ServerPreparedStatement (no replies)

$
0
0
Use 6.0.6 version, enable useServerPrepStmts.
The statement is cached by connection, the statement will remain until the connection is really closed.

Suppose a statement query "select * from xxx",
then "alter table xxx add column fx...",
query "select * from xxx" again,
throw an exception:

Exception in thread "main" java.sql.SQLException: java.lang.ArrayIndexOutOfBoundsException: 5
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)
at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:724)
at com.mysql.cj.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)

I have to enable useServerPrepStmts to improve performance and save cost.
My application need "select *", alter table column, then "select *" in the same statement.

So I modify the MergingColumnDefinitionFactory's createFromFields, refresh columnDefinitionFromCache:

public ColumnDefinition createFromFields(Field[] fields) {
return this.columnDefinitionFromCache = new MysqlaColumnDefinition(fields);
}

Does't merge the flags, may be have some unknow issue.
Is there an elegant way to meet the needs?

Performance Impact of rollback() Immediately after a commit(). (no replies)

$
0
0
Recently our team moved to the following approach (we have valid reasons why and my question is not about this solution):

try (DbSession session = daoFactory.openSession()) {

// JDBC Execution with session.getConnection()

// Explicit commit required for inserts/updates/deletes
// No explicit commit required for selects
}

Our DbSession object wraps a JDBC Connection and implements AutoCloseable. Our close() implementation always calls connection.rollback() (again for reasons that are independent of my question).

The net effect is we either have inserts/updates/deletes with a commit, which is immediately followed by a rollback

Or, we have selects which are just followed by a rollback.

My question is about the performance impact of calling rollback() immediately after a commit(), and if there are any?

So what is the impact of doing a commit and then a rollback on performance for a production environment? Is it zero or is it something that we should consider? Does the JDBC driver handle this as a NOOP (I hope so)? Or is this an actual networked call to the database server?

Thanks!!!!

Licensing - community vs. commercial (no replies)

$
0
0
Hi,

I've been asked whether the version of the connector (mysql-connector-java 5.1.9) we're using is the commercial or the community version. I was under the impression that the only difference between the two is the licensing.

Is this true?

If not, how can I tell which version of the connector I have?

Thanks,
Mike

No enum constant mysql.cj.conf.PropertyDefinitions.ZerodatetimeBehaviour.CONVERTTONULL using MySQL Community Server 8.0.11 and NetBeans 8.0.2 (no replies)

$
0
0
I have just upgraded my installation of MySQL to the Community Edition 8.0.11.0 and all of the relavant database schemas have been restored correctly with appropriate authorities.

However, when trying to run a Java application in NetBeans 8.0.2 which connects to the database, I receive messages in NetBeans saying that:

"No enum constant MySql.cj.conf.PropertyDefinitions.ZerodatetimeBehaviour.CONVERTTONULL"

Furthermore, the following messages also appear:

"2018-04-21T00:59:31.427055Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.11) starting as process 25496
mysqld: Table 'mysql.plugin' doesn't exist
2018-04-21T00:59:33.444111Z 0 [ERROR] [MY-010735] [Server] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-04-21T00:59:33.907490Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-21T00:59:35.066791Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-04-21T00:59:35.071764Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Unknown error
2018-04-21T00:59:35.071936Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ?
2018-04-21T00:59:35.072186Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-04-21T00:59:36.466971Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL."

My application has the mysql-connector-java-8.0.11.jar and this file has also been added to NetBeans.

I believe that my MySQL settings in NetBeans are correct: for file mysqld.exe I have options --console --datadir=C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data\\. And for mysqladmin.exe I have -u root shutdown.

So can anyone advise why I have these messages?

MySQL 8.0: Connector/J (no replies)

Today new update! (no replies)


[Q] Best method to create a rest api with an already existing database. (1 reply)

$
0
0
I am trying to develop a RESTful web service with Java and most of the examples are creating the database from scratch. Javascript let us access the database and create it but the people that we are creating this project for asked us to switch to Java. We want to access and use the existing database we created and create the restful service.

We have tried using spring, gradle, and jersey. Most of the guides are for making a connection and creating the database but not using an existing one already.

Hanging threads on com.mysql.jdbc.ConnectionImpl.setAutoCommit (no replies)

$
0
0
We have a server system where the following DB layer is used: hibernate 4.3.7, c3p0 0.9.5.2, mysql-connector-java 5.1.46.
MySQL 5.7.21 (and also 5.5.60) is a standalone DB server.
After ~2 days of the system uptime some threads start to hang on the following point:

"Synchronizer: (??????? ?????????? / ??????????)" daemon prio=4 tid=0x00000010ecef9800 nid=0x8148 runnable [0x000000109f97e000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:112)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:159)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:187)
- locked <0x000000093429eaa0> (a com.mysql.jdbc.util.ReadAheadInputStream)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3158)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3615)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3604)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4155)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2832)
- locked <0x0000000c8ab1dbf8> (a com.mysql.jdbc.JDBC4Connection)
at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5357)
- locked <0x0000000c8ab1dbf8> (a com.mysql.jdbc.JDBC4Connection)
at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:1085)
- locked <0x000000093509a148> (a com.mchange.v2.c3p0.impl.NewProxyConnection)
at org.hibernate.c3p0.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:94)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:380)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:228)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:171)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:162)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1435)
...

Same threads usually operates normally, but after 2 days the number of hanging threads slowly start to increase.
The system became more and more unresponsive and we have to restart it.
Hanging threads are not hanging indeed, they are reading sockets and waiting for the response from the MySQL DB engine.
But reply never happens and we've came to errors like: 'The last packet successfully received from the server was ..... milliseconds ago. Longer than 'wait_timeout' ...'
At the same time other similar ('Synchronizer') threads work perfect.

When the hang happens SHOW FULL PROCESSLIST displays some long-sleeping processes:

Id User Host db Command Time State Info
266707 root localhost:57373 aggregate Sleep 295 NULL <-- like this
266953 root localhost:58471 aggregate Sleep 177 NULL
268071 root localhost:64882 aggregate Sleep 1 NULL
268178 root localhost:65415 aggregate Sleep 1 NULL
268233 root localhost:49234 aggregate Sleep 1 NULL
268236 root localhost:49237 aggregate Sleep 1 NULL
...
268369 root localhost:49919 NULL Query 0 NULL show full processlist

Does anyone has some thoughts how JDBC threads can come to the orphan state hanging on socket read?

Memory Leak warning in Tomcat when using com.mysql.cj.jdbc(mysql-connector-java Version 8.0.11) (no replies)

$
0
0
I am using Tomcat 9.0.8 with MySQL database Ver 8.0.11 and mysql-connector-java Version 8.0.11

I have implemented a Listener and in the contextDestroy(), I am de-registering all the JDBC drivers as below:

Enumeration<Driver> l_drivers = DriverManager.getDrivers();
while (l_drivers.hasMoreElements()) {
Driver l_driver = l_drivers.nextElement();
try {
LOGGER.info("De-registering JDBC driver :: {}",l_driver.getClass().getName());
DriverManager.deregisterDriver(l_driver);
} catch (Exception e) {
LOGGER.error("Error deregistering Driver:: {}", l_driver);
LOGGER.error(e.getMessage(), e);
}
}


But still every time I re-deploy/re-load/shutdown I get the below memory leak warning message in Tomcat Logs:

13-May-2018 00:02:01.354 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads
The web application [xxxxx] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it.
This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:70)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
13-May-2018 00:02:01.387 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8082"]
13-May-2018 00:02:01.392 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8010"]
13-May-2018 00:02:01.397 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8082"]
13-May-2018 00:02:01.398 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8010"]

So I am not sure why I still get this warning? I have another web-app which runs with MySQL 5.7 and MySQL Connector 6.0.6 and there I am not facing this issue with exactly same code in the contextDestroy().

Am I missing something in the version 8?

OS: Ubuntu 18.04 LTS, Java 1.8

CommunicationsException when using cursor-based fetch of large dataset (no replies)

$
0
0
Hi folks,

We are using Connector/J version 5.1 in our app to read a large number of rows (~7M) and fairly large dataset (~27 GB). We were hitting timeouts with streaming results row-by-row:

val conn = DriverManager.getConnection(
connectionConfig.connectUrl.toStr,
connectionConfig.userName.toStr,
connectionConfig.password.toStr
)
val stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)
val rs: ResultSet = stmt.executeQuery(selectQuery)

The error we received:
The last packet successfully received from the server was 4,311 milliseconds ago. The last packet sent successfully to the server was 4,311 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1038)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3434)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3334)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3774)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2541)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2499)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1432)
at com.twitter.scalding_internal.db.jdbc.JdbcToHdfsCopier$$anonfun$2.apply(JdbcToHdfsCopier.scala:65)
at com.twitter.scalding_internal.db.jdbc.JdbcToHdfsCopier$$anonfun$2.apply(JdbcToHdfsCopier.scala:51)
at scala.util.Success$$anonfun$map$1.apply(Try.scala:237)
at scala.util.Try$.apply(Try.scala:192)
at scala.util.Success.map(Try.scala:237)
at com.twitter.scalding_internal.db.jdbc.JdbcToHdfsCopier$.apply(JdbcToHdfsCopier.scala:51)
... 76 more
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3344)
... 89 more


So we switched to using cursor-based fetch by providing the useCursorFetch=true config property and setting fetch size = 50.

stmt.setFetchSize(50)

This has eliminated the EOFExceptions, which we thought was due to the fact that we are now making requests to the database more frequently to fetch results using the database cursor. However, we started seeing a new error:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 900,055 milliseconds ago. The last packet sent successfully to the server was 900,055 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1038)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3434)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3334)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3774)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1288)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:794)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1193)
at com.mysql.jdbc.StatementImpl.createResultSetUsingServerFetch(StatementImpl.java:666)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1394)
... 76 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:100)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:143)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:173)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2923)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3344)
... 90 more

This was observed when issuing select statements for smaller chunks of our data (~2 million rows at a time).

Since it is a shared MySQL cluster used at our company, I don't believe changing the server-side configuration 'wait_timeout' is an option for us. We also tried to add the autoReconnect=true parameter to the connection string, but the errors still occasionally occur.

Are there some debugging steps we could take here to understand the cause? Does cursor based fetch not issue several requests to the database that should prevent us from hitting the timeout? Should we be issuing even more requests in smaller chunks so that we reduce the risk of hitting this timeout?

I'm also wondering if autoReconnect is doing anything here. With cursor fetch, if a request fails and the driver attempts to reconnect with the next request, does it try to re-run the existing SELECT statement with cursor fetch, or will it try to fetch the next set of data after advancing the cursor? I am not sure I have observed either behavior, but definitely want to avoid dropping data in case of connection failure.

Thank you,
Mark

Connector/J 8 timezone issue (no replies)

$
0
0
Hi,
I use JDK 8, Tomcat 8 and Connector/J 8. My JVM got GMT+1 for timezone. JDBC does timezone conversion for every DATE value that comes from the client, before sending them to MYSQL. Setting "serverTimezone=UTC" doesn't solve my problem. It seems that properties like "useLegacyDatetimeCode" and "noTimezoneConversionForDateType" aren't available in Connector/J 8 (I can't find them in the official Developer Guide). Please help. Thank you.
Viewing all 884 articles
Browse latest View live


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