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

java.sql.Date error (1 reply)

$
0
0
I just installed the MySQL Connector J (Version 5.1.22). I then created a document using LibreOffice (Version 3.6.4) Base to connect to a MySQL database. My initial queries and reports work well with one exception. I receive an error which says, "Value '0000-00-00' can not be represented as java.sql.Date", when I attempt to display a table which does contain dates. It seems like having unknown dates is quite normal and MySQL should be able to store them as it chooses. If java wants them in a different form, which of course is irrelevant to a user of LibreOffice Base, then isn't it the purpose of the JDBC connector to handle that properly. The Base user trying to create queries and reports is not able to dictate how information is stored in the database.

Is this a bug in the connector, or possibly LibreOffice, or have I overlooked something?

JDBC URL String and Driver Information of All Databases (no replies)

new connection implicitly created when autoReconnect was disabled (1 reply)

$
0
0
Hi,

I am experiencing some strange behavior related to "autoReconnect" parameter.

Here are the steps for a simple test i have run:

1 - get a connection from driver (having autoReconnect=false in the url)
2 - execute an sql
3 - make the master (primary) server unavailable (i.e. unplug network cable)
4 - execute sql on the connection (SHOULD fail)
5 - execute sql on the same connection again (SHOULD fail)
* monitor tcp connections throughout the test. NO connections to slave host should be opened.

url: jdbc:mysql://dbmaster,dbslave:3306/TESTDB?autoReconnect=false&connectTimeout=5000&socketTimeout=30000&relaxAutoCommit=true&
failOverReadOnly=false&characterEncoding=UTF-8

connector/j : 5.1.18 (and 5.1.22 with same results)

java: 1.6(.0.37)


I assumed that connector/j would not automatically "reconnect" a connection when autoReconnect was disabled.

But it seems that a connection is created against the slave(dbslave) at step 5. (at which the connection had already received a communications exception)

any comments?

thanks

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException (1 reply)

$
0
0
do
{
String mid=res.getString(1);
String model=res.getString(2);
String name=res.getString(3);
int price=res.getInt(4);
String pcolor=res.getString(5);
String imei=res.getString(6);
java.sql.Date date=res.getDate(7);
String access=res.getString(8);

if(id.equals(mid) || id.equals(imei))
{
System.out.println("iam inside");

PreparedStatement prp=con2.prepareStatement("insert into msearch values(?,?,?,?,?,?,?,?)");
prp.setString(1,mid);
prp.setString(2,model);
prp.setString(3,name);
prp.setInt(4,price);
prp.setString(5,pcolor);
prp.setString(6,imei);
prp.setDate(7,date);
prp.setString(8,access);

prp.executeUpdate();

System.out.println("iam inside2");
rows++;

b=1;
jTextField1.setText("");
}


}while(res.next());



I am new to mysql
I am trying to execute above code ,I got com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

what should be the problem,please help,

loadbalance url : statement vs preparedstatement (no replies)

$
0
0
Hi,

Is there a difference between using regular statements vs using prepared statements in regards to rebalancing behaviour of connector/j?

I execute the following:

1. get connection from driver
2. make the first host (host1) unavailable
3. execute some sql on the connection (should fail). sql="select field1 from nonexistingtable"

url: "jdbc:mysql:loadbalance://host1,host2:3306/TESTDB?autoReconnect=false&connectTimeout=5000&socketTimeout=30000&relaxAutoCommit=true&failOverReadOnly=false&characterEncoding=UTF-8"

connector/j : 5.1.18

java: 1.6.0.37

If i execute the 3rd step using regular statements, a physical connection to host2 is established. (query fails after sockettimeout ms)

But if i execute the same step using a prepared statement, no physical connections are established to host2. (query fails after sockettimeout ms)

Is there a reason why they behave differently? Is this expected behaviour?

Actually i am trying to validate the connection, and i read somewhere that the validation query should start with "/* ping */", especially for a loadbalanced configuration. Does anyone know what this "ping" query actually does?

thank you

querytimeout doesn't work for load-balanced and fail-over urls (3 replies)

$
0
0
Hi,

Setting queryTimeout() seems to have no effect when using loadbalanced url.

I am using a query that takes more than 5s to execute with the following code:

Connection conn = DriverManager.getConnection(url);
PreparedStatement ps = conn.prepareStatement(aLongRunningSql);
ps.setQueryTimeout(2);
ResultSet rs = ps.executeQuery();

Using:
java 1.6
connector/j 5.1.22
url : jdbc:mysql:loadbalance://host1,host2:3306/test?connectTimeout=3000&socketTimeout=5000

The following exception is caught after socketTimeout ms, and at that point the connection starts to point to host2:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 5,102 milliseconds ago. The last packet sent successfully to the server was 5,006 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3589)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3478)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4019)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.LoadBalancedMySQLConnection.execSQL(LoadBalancedMySQLConnection.java:156)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.executeSql(ConnectorJSocketTimeoutTest.java:73)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.run(ConnectorJSocketTimeoutTest.java:47)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.main(ConnectorJSocketTimeoutTest.java:97)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3036)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3489)
... 11 more
error info : sql state=08S01 error code=0 type=com.mysql.jdbc.exceptions.jdbc4.CommunicationsException cause=java.net.SocketTimeoutException: Read timed out

Looking at the thread dump (somewhere after 2s and before 5s after issuing the query):

"Thread-1" daemon prio=10 tid=0x00007f9308001000 nid=0x30eb waiting for monitor entry [0x00007f9351a73000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.mysql.jdbc.LoadBalancedMySQLConnection.getActiveMySQLConnection(LoadBalancedMySQLConnection.java:51)
- waiting to lock <0x00000007d6ee4760> (a com.mysql.jdbc.JDBC4LoadBalancedMySQLConnection)
at com.mysql.jdbc.LoadBalancedMySQLConnection.getQueryTimeoutKillsConnection(LoadBalancedMySQLConnection.java:592)
at com.mysql.jdbc.StatementImpl$CancelTask$1.run(StatementImpl.java:107)

"MySQL Statement Cancellation Timer" daemon prio=10 tid=0x00007f935c844000 nid=0x30d1 in Object.wait() [0x00007f9351b74000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007d74db358> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:485)
at java.util.TimerThread.mainLoop(Timer.java:483)
- locked <0x00000007d74db358> (a java.util.TaskQueue)
at java.util.TimerThread.run(Timer.java:462)

"Abandoned connection cleanup thread" daemon prio=10 tid=0x00007f935c0e5800 nid=0x30d0 in Object.wait() [0x00007f935206f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007d6b04278> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
- locked <0x00000007d6b04278> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
at com.mysql.jdbc.NonRegisteringDriver$1.run(NonRegisteringDriver.java:93)

"main" prio=10 tid=0x00007f935c00e800 nid=0x30b5 runnable [0x00007f9362121000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
- locked <0x00000007d71979a0> (a com.mysql.jdbc.util.ReadAheadInputStream)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3036)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3489)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3478)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4019)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
- locked <0x00000007d701c998> (a com.mysql.jdbc.JDBC4Connection)
at com.mysql.jdbc.LoadBalancedMySQLConnection.execSQL(LoadBalancedMySQLConnection.java:156)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
- locked <0x00000007d6ee4760> (a com.mysql.jdbc.JDBC4LoadBalancedMySQLConnection)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
- locked <0x00000007d6ee4760> (a com.mysql.jdbc.JDBC4LoadBalancedMySQLConnection)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.executeSql(ConnectorJSocketTimeoutTest.java:73)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.run(ConnectorJSocketTimeoutTest.java:47)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.main(ConnectorJSocketTimeoutTest.java:97)

The querytimeout thread ("Thread-1") has actually started, but was waiting to lock <0x00000007d6ee4760>, which is already locked by "main" thread issuing the query. But at the time it acquires the lock, it probably is too late.

I have also tried with a fail-over url and got similar results.

I should note that everything works as expected when using a basic url, i.e. jdbc:mysql://host1:3306/test?connectTimeout=3000&socketTimeout=5000

After 2 seconds it fails with :
com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2841)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.executeSql(ConnectorJSocketTimeoutTest.java:73)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.run(ConnectorJSocketTimeoutTest.java:47)
at com.acme.util.database.connectionPooling.test.manual.ConnectorJSocketTimeoutTest.main(ConnectorJSocketTimeoutTest.java:97)
error info: sql state=null error code=0 type=com.mysql.jdbc.exceptions.MySQLTimeoutException cause=null

Any comments?

thanks

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure (2 replies)

$
0
0
Hi,
Sorry for my Ebglish.
I have a strange problem, getting com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
in a netbeans desktop application that has a connection to a remote server . MySql database located in the server.
I am getting the connection once:
con = DriverManager.getConnection(connectionUrlInternet);
Then I am creating statements on this connection to update/insert data.
My system worked just fine for 1.5 years , once a week I had those
Communications link failure if at all.
Lately I am getting the failure every few minutes, the meanning - we cannot work.
The remote server manager cannot solve the problem - he didn't change anything.
He wants me to get the connection before each operation and close it.

Any idea please, I am lost.

Thank you
Miriam

Can't connect to database. (no replies)

$
0
0
I have an application using a servlet that I cannot get to connect to the database using a datasource. I am able to connect to the database using the following code:

Class.forName(DRIVER).newInstance();
Connection conn = DriverManager.getConnection(url + dbName, userName, password); config.setBillReviewConn(conn);

This works fine and I am able to connect to my localhost via the url jdbc:mysql://127.0.0.1:3306/

However, when I cahnge the code to use a datasource using the following code:

Context ctx = (Context) new InitialContext().lookup("java:comp/env");
String database = "jdbc/" + profile;
DataSource ds = (javax.sql.DataSource) ctx.lookup ("jdbc/mysql");
config.setBillReviewConn(ds.getConnection());

The ds.getConnection is producing the following stacktrace:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (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.)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at com.mcmcllc.brs.servlet.Server.service(Server.java:69)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2332)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
... 20 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:218)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)


I've tried multiple things to correct the issue such as replacing localhost with 127.0.0.1, turning off my firewall, etc.

I guess I don't understand how I can connect using the first snippet of code.

Any help would be great. Thanks.

learn online progamming (no replies)

$
0
0
hi everyone
Every body want to learn programming langauges bcoz this is the time of computer technology.
so here i provide the information about many programming langauges.
learn programming online (c,c++,java and many more)
here you find tutorials and programming illustration of algorithms.
----------------------------
java tutorials
c tutorials
c++ tutorials

Can't retrieve Employee_Name + Total Gross Income (3 replies)

$
0
0
String str = "select  e.Employee_Name, sum(i.Subincome)  from employee e RIGHT  JOIN income i "
 + "ON e.Employee_ID = i.Employee_ID "  + " where e.Employee_ID = "
 + emp_id + " group by e.Employee_Name";

pst = conn.prepareStatement(str);
rs = pst.executeQuery();
             
Employee_Name = rs.getString(1);
totalIncome = rs.getBigDecimal(2);
Error:
java.sql.SQLException: Before start of result set
	at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:3624)
	at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1762)
	at edica.CDatabase.calculateTotalIncome(CDatabase.java:368)
Please help
Thx

timestamp and daylight saving (1 reply)

$
0
0
I'm running a matlab function (fastinsert) to insert data into MySQL. The results are correct for the whole year except for 1 hour in March, during daylight saving. In fact it seems that I cannot insert data between 2:00am and 3:00am on that day.

For example with:

ts = 2006 3 26 2 30 0

looking within the matlab function I found that the problem lies into:

java.sql.Timestamp(ts(1)-1900,ts(2)-1,ts(3),ts(4),ts(5),secs,nanosecs)

that gives as a result:

2006-03-26 03:30:00.0

So using java.sql.Timestamp I have a +1h shift ONLY during the single hour of daylight saving in the end of March.
How can I solve this?

JDK 7 support with mysql-connector-java-5.1.23 (3 replies)

$
0
0
Hello,

Does anyone confirm that JDK 7u13 is supported with mysql-connector-java-5.1.23?

And also share if anyone face any issue with JDK 7 with MySQL Java 5.1.23 connector?

Thanks,
-Praveen Soni

Connector/MXJ not shutting down on Windows shutdown? (no replies)

$
0
0
I know that Connector/MXJ is end-of-life; however, I'm hoping someone on the forums might be able to answer a question for me.

We have an applicaton that's using MySQL Community Edition 5.5.9 and MySQL Connector/MXJ version 5.0.12. We use Connector/MXJ to start up and shut down the MySQL server. Our Java app has a shutdown hook registered so that we can call MysqldResource.shutdown() if our app is terminated. However, we are frequently noticing that if a user shuts down Windows without shutting our app down first, that we get stderr output similar to the following the next time we start MySQL:

130227 10:33:42 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Last MySQL binlog file position 0 1096, file name .\binary-log.000003
130227 10:33:44 InnoDB: Waiting for the background threads to start
130227 10:33:45 InnoDB: 1.1.5 started; log sequence number 12184427
130227 10:33:45 [Note] Recovering after a crash using binary-log
130227 10:33:45 [Note] Starting crash recovery...
130227 10:33:45 [Note] Crash recovery finished

In my web searches for this issue, I was able to find only this seven-year old mailing list post that seems to directly address our situation:

http://marc.info/?l=mysql-java&m=115918657823630&w=2

Can anyone tell me if the latest version of Connector/MXJ still has a problem shutting down cleanly under Windows? Also, this old mailing list post seems to suggest that these messages are harmless and that the situation will not result in data loss; is this still accurate?

Any assistance would be appreciated.

Thanks,
Don

Performance problems with executeUpdate (no replies)

$
0
0
Hi All,

I'm experiencing performance issues under MySQL 5.6.10 (and also tested under 5.5.24).

Running a bunch of DDL statements for bootstrapping the application, I've found that something simple as:

Statement drop = conn.createStatement();
long time = System.currentTimeMillis();
drop.executeUpdate("DROP TABLE TEST");
System.out.println("took: "+(System.currentTimeMillis() - time));

Takes in average 300 ms.

The full bootstrap of the application takes about 15 seconds while that the same code for SQLServer, Oracle and Postgres takes about 2 ~ 4 seconds.

The (drop) executeUpdate statements in the other engines take about 1 ~ 10 ms.


Any Ideas?

LoadBalancingConnectionProxy and /* ping */ select 1 (2 replies)

$
0
0
Hi there,

Having read http://dev.mysql.com/doc/refman/5.5/en/connector-j-usagenotes-j2ee-concepts-connection-pooling.html, the document is a little confusing
when it comes to describing what occurs when a correctly formatted ping is issued and there is more than one slave connection.

The documentation seems to indicate that when a correctly formatted /* ping */ select 1 is issued, all the connections are
validated:

"All of the previous statements will issue a normal SELECT statement and will not be transformed
into the lightweight ping. Further, for load-balanced connections, the statement will be executed
against one connection in the internal pool, rather than validating each underlying physical connection."


The above seems to indicate that if I have more than one slave in the jdbc url, and the correct ping,
when the ping will be sent to all the slave connections. However, this does not seem to be the case, and
the docs isn't too clear on what "each underlying physical connection" actually means.


So to dechiper the above, if you have the following connection (and the ReplicationDriver set) configured:

jdbc:mysql:replication://master,slave1,slave2


You are going to get a LoadBalancedMySQLConnection that load balances over slave1, and slave2. When a connection given to the app, it is given a ReplicationConnection that is pointing at master, and the previous
LoadBalancedMySQLConection.

When the validation query is run, which of the following should be the case?:

1) Should all the connections be sent the Administrator Ping command: master, slave1, and slave2.
2) Should just master and 1 currently active slave connection get the ping


1 would be ideal, 2 is the current implementation it seems.

To validate this, I monitored the network traffic, and noticed that when the ping command is issued
it also goes to one slave connection, not all of them.

The /* ping */ select 1, validation query is ONLY going to be sent to master, and the currently
active slave connection i.e. slave1, if slave1 is the currently active slave connection. This can be
as can be seen below from a trace of network traffic on my local machine. The ping isn't sent to
all the slaves, just one of them.

- master Ping

# 2013-01-09 13:52:04.065269 0:00 1 use ?
# 2013-01-09 13:52:04.065409 0:00 1 select @@session.tx_isolation
# 2013-01-09 13:52:14.066863 0:00 1 administrator command: Ping
# 2013-01-09 13:52:14.068020 0:00 1 select @@session.tx_isolation
# 2013-01-09 13:52:14.069128 0:00 1 use ?
# 2013-01-09 13:52:14.069292 00:00 2 select @@session.tx_isolation

- slave1 Ping

# 2013-01-09 13:52:04.063467 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:04.063661 0:00 1 commit
# 2013-01-09 13:52:14.067116 0:00 1 administrator command: Ping
# 2013-01-09 13:52:14.068570 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.068911 0:00 1 commit
# 2013-01-09 13:52:14.070439 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.070659 0:00 1 commit
# 2013-01-09 13:52:14.073957 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.074149 0:00 1 commit

- slave2 No Ping

# 2013-01-09 13:52:04.058715 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:04.058999 0:00 1 commit
# 2013-01-09 13:52:04.064923 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:04.065104 0:00 1 commit
# 2013-01-09 13:52:14.072204 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.072462 0:00 1 commit
# 2013-01-09 13:52:14.076941 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.077132 0:00 1 commit
# 2013-01-09 13:52:14.080233 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.080439 0:00 1 commit
# 2013-01-09 13:52:14.081736 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.081943 0:00 1 commit
# 2013-01-09 13:52:14.083229 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.083450 0:00 1 commit
# 2013-01-09 13:52:14.084890 0:00 1 select count(*) from items where ?=?
# 2013-01-09 13:52:14.085093 0:00 1 commit
# 2013-01-09 13:52:14.088043 0:00 1 select count(*) from items where ?=?

(I validated the above against 5.1.23 connector/j today also)

- slave and master

# 2013-03-08 14:02:26.153069 00:00 2 select @@session.tx_isolation
# 2013-03-08 14:02:26.250658 0:00 1 use ?
# 2013-03-08 14:02:26.250845 00:00 2 select @@session.tx_isolation
# 2013-03-08 14:02:26.354493 0:00 1 use ?
# 2013-03-08 14:02:26.354737 0:00 1 select @@session.tx_isolation
# 2013-03-08 14:03:06.355238 00:00 2 administrator command: Ping
# 2013-03-08 14:03:06.355998 0:00 1 select @@session.tx_isolation
# 2013-03-08 14:03:06.481647 0:00 1 select count(*) from items where ?=?
# 2013-03-08 14:03:06.482130 0:00 1 commit
# 2013-03-08 14:03:06.482412 0:00 1 use ?
# 2013-03-08 14:03:06.482628 0:00 1 select @@session.tx_isolation

- slave2 (No Ping)

# 2013-03-08 14:02:26.136844 0:00 1 administrator command: Connect
# 2013-03-08 14:02:26.139105 0:00 1 show variables where variable_name =? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ? or variable_name = ?
# 2013-03-08 14:02:26.140235 0:00 1 select @@session.auto_increment_increment
# 2013-03-08 14:02:26.142008 0:00 1 show collation
# 2013-03-08 14:02:26.151043 0:00 1 set names utf?
# 2013-03-08 14:02:26.151393 0:00 1 set character_set_results = ?
# 2013-03-08 14:02:26.151770 0:00 1 set autocommit=?
# 2013-03-08 14:02:26.249067 0:00 1 select count(*) from items where ?=?
# 2013-03-08 14:02:26.249905 0:00 1 commit
# 2013-03-08 14:02:26.352923 0:00 1 select count(*) from items where ?=?
# 2013-03-08 14:02:26.353696 0:00 1 commit



The problem the above causes is that if an application is using the tomcat JDBC Connection Pool,
with testOnBorrow set to true, and a validationInterval of say 30 seconds. There is potential for
an application to be given back an idle slave connection. As the when the connection is borrowed from the pool,
it may or may not be validated depending upon the "validationInterval"

DBCP for instance, issues the validation query (when testOnBorrow is true), whenever a connection is
borrowed from the connection pool. If the mysql connector/j hands back a slave connection that is idle
the validation query catches that. However, what this results in, is a database whose job is handling a lot of Ping commands,
as one of it's top queries. The tomcat pool (http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency)
performs this connection validation periodically (based on a validationInterval) so your database isn't constantly validating connections from applications.

I can see that there is "loadBalanceValidateConnectionOnSwapServer=true", so that the idle slave connection
would be caught before it is given back to the client as the active slave connection (useable in 5.1.23). Although,
this would result in what almost equivalent of the DBCP ping on borrow always semantics.


Should the ping query be going to all slaves (Is this a bug)?
If not, is this potentially a feature request to add a property that allows it to validate against all currently established slave connections?
Or Am I missing another connector/j url property to make the ping hit all slaves?


cheers
/dom

Communications link failure after a while (no replies)

$
0
0
hi ,

after a while (day or two) we get the exception below , after we used to have this error i implemented a pool of connections based on org.apache.commons.pool.BasePoolableObjectFactory , with this configuration:

Config config = new GenericObjectPool.Config();
config.maxActive = 30;
config.testOnBorrow = true;
config.testWhileIdle = true;
config.timeBetweenEvictionRunsMillis = 5000;
config.minEvictableIdleTimeMillis = 60000;

when i tried to get timeout in QA environment after a shorter time by changing the wait_timeout of the mySql to 30 minuts i got no error .
this is the exception i get in production :


com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 13 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3134)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1818)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888)
at com.commtouch.auth.CacheHolder.getKeyFromDB(CacheHolder.java:357)
at com.commtouch.auth.CacheHolder.get(CacheHolder.java:262)
at com.commtouch.auth.ByPassMechanism.checkInDB(ByPassMechanism.java:134)
at com.commtouch.auth.ByPassMechanism.ByPassGeneral(ByPassMechanism.java:84)
at com.commtouch.auth.ByPassMechanism.ByPass(ByPassMechanism.java:55)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatc
hProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3119)
... 44 more


thanks

JDBC and date translation (no replies)

$
0
0
Hi all,

I connect to a MySQL database with a JDBC driver. In a table, I have a DATE type column with some values like '2008-00-00'.
With MySQL Query Browser the result is '2008-00-00' but with Squirrel (JDBC driver) the result is '2007-11-30'.
Is there any option in the JDBC driver to get the value format like '2008-00-00'. I had a look at http://dev.mysql.com/doc/refman/5.5/en/connector-j-reference-configuration-properties.html, but couldn't manage to find the right property.

If anyone has already encountered this problem, is there somewhere I can configure this behavior ?

Regards

does not list the table comments as stated in driver documentation (no replies)

$
0
0
Method jdbcConnection.getMetaData().getTables(....) does not list the table comments as stated in driver documentation:

* Each table description has the following columns:
*

*
TABLE_CAT String => table catalog (may be <code>null</code>)
*
TABLE_SCHEM String => table schema (may be <code>null</code>)
*
TABLE_NAME String => table name
*
TABLE_TYPE String => table type. Typical types are "TABLE",
* "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
* "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
*
REMARKS String => explanatory comment on the table
*
TYPE_CAT String => the types catalog (may be <code>null</code>)
*
TYPE_SCHEM String => the types schema (may be <code>null</code>)
*
TYPE_NAME String => type name (may be <code>null</code>)
*
SELF_REFERENCING_COL_NAME String => name of the designated

mysql, number of TCP connections does not match on server / client machines (no replies)

$
0
0
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 419
Server version: 5.1.67-0ubuntu0.11.10.1 (Ubuntu)

jdbc-mysql.jar version: unknown - how do I check this ?

root@XMPP:/opt/tigase# java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~11.10.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

As reported by netstat (client side) "show processlist" mysql command and netstat (server side). TCP state is "ESTABLISHED" on boths sides.

Server side (xx.xx.xx.241)

mysql> show processlist;
+-----+-------------+--------------------+----------+---------+------+-------+------------------+
| Id  | User        | Host               | db       | Command | Time | State | Info             |
+-----+-------------+--------------------+----------+---------+------+-------+------------------+
| 100 | tigase_user | xx.xx.xx.25:23820 | tigasedb | Sleep   |  921 |       | NULL             | 
| 101 | tigase_user | xx.xx.xx.25:23821 | tigasedb | Sleep   | 6664 |       | NULL             | 
| 102 | tigase_user | xx.xx.xx.25:23822 | tigasedb | Sleep   | 6664 |       | NULL             | 
| 103 | tigase_user | xx.xx.xx.25:23823 | tigasedb | Sleep   | 6664 |       | NULL             | 
| 104 | tigase_user | xx.xx.xx.25:23824 | tigasedb | Sleep   | 6664 |       | NULL             | 
| 105 | tigase_user | xx.xx.xx.25:23825 | tigasedb | Sleep   | 6664 |       | NULL             | 
| 106 | tigase_user | xx.xx.xx.25:23826 | tigasedb | Sleep   | 6664 |       | NULL             | 
| 107 | tigase_user | xx.xx.xx.25:23827 | tigasedb | Sleep   | 6654 |       | NULL             | 
| 108 | tigase_user | xx.xx.xx.25:23828 | tigasedb | Sleep   |  921 |       | NULL             | 
| 115 | tigase_user | xx.xx.xx.25:23835 | tigasedb | Sleep   | 6667 |       | NULL             | 
| 116 | tigase_user | xx.xx.xx.25:23836 | tigasedb | Sleep   | 6667 |       | NULL             | 
| 117 | tigase_user | xx.xx.xx.25:23837 | tigasedb | Sleep   | 6667 |       | NULL             | 
| 118 | tigase_user | xx.xx.xx.25:23838 | tigasedb | Sleep   | 6667 |       | NULL             | 
| 119 | tigase_user | xx.xx.xx.25:23839 | tigasedb | Sleep   | 6667 |       | NULL             | 
| 143 | tigase_user | xx.xx.xx.25:23864 | tigasedb | Sleep   |  921 |       | NULL             | 
| 144 | tigase_user | xx.xx.xx.25:23866 | tigasedb | Sleep   |  921 |       | NULL             | 
| 145 | tigase_user | xx.xx.xx.25:23867 | tigasedb | Sleep   |  654 |       | NULL             | 
| 153 | tigase_user | xx.xx.xx.25:23875 | tigasedb | Sleep   |  921 |       | NULL             | 
| 166 | tigase_user | xx.xx.xx.39:45214 | NULL     | Query   |    0 | NULL  | show processlist | 
+-----+-------------+--------------------+----------+---------+------+-------+------------------+
19 rows in set (0.00 sec)

Client side (xx.xx.xx.25):

root@XMPP:/opt/tigase# netstat -antop | grep "xx.xx.xx.241:3306" | wc -l
20
root@XMPP:/opt/tigase# netstat -antop | grep "xx.xx.xx.241:3306" 
tcp        0     74 xx.xx.xx.25:23846      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (75.60/12/0)
tcp        0    348 xx.xx.xx.25:23863      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (75.06/12/0)
tcp        0    348 xx.xx.xx.25:23829      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (75.06/12/0)
tcp        0      0 xx.xx.xx.25:23866      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.85/0/0)
tcp        0     74 xx.xx.xx.25:23845      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (79.66/12/0)
tcp        0     55 xx.xx.xx.25:23849      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (75.56/12/0)
tcp        0      0 xx.xx.xx.25:23870      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.83/0/0)
tcp        0     45 xx.xx.xx.25:23871      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (75.03/12/0)
tcp        0      0 xx.xx.xx.25:23868      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.82/0/0)
tcp        0      0 xx.xx.xx.25:23869      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.82/0/0)
tcp        0      0 xx.xx.xx.25:23875      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5665.19/0/0)
tcp        0      0 xx.xx.xx.25:23864      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.80/0/0)
tcp        0      0 xx.xx.xx.25:23872      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.79/0/0)
tcp        0      0 xx.xx.xx.25:23820      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (962.67/0/0)
tcp        0     74 xx.xx.xx.25:23848      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (75.51/12/0)
tcp        0    348 xx.xx.xx.25:23874      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (74.99/12/0)
tcp        0     55 xx.xx.xx.25:23850      xx.xx.xx.241:3306      ESTABLISHED 10222/java       on (79.59/12/0)
tcp        0      0 xx.xx.xx.25:23828      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (962.65/0/0)
tcp        0    228 xx.xx.xx.25:23873      xx.xx.xx..241:3306      ESTABLISHED 10222/java       on (83.17/12/0)
tcp        0      0 xx.xx.xx.25:23867      xx.xx.xx.241:3306      ESTABLISHED 10222/java       keepalive (5648.76/0/0)
As it can be seen, client shows 20 connections to the mysql server - which only shows 18 connections. Other time I have spotted a gap of 10 missing connections (10 reported at server vs 20 opened by client, or even a gap of 17: 22 client vs 5 server). The situation persists for some good minutes - not more than 15 I think - and then the number of connections starts to change (sometimes to the desired 20 / 20, but not sure how stable it stays there).

Connections are opened the regular way through Java code:

        conn = DriverManager.getConnection(db_conn);

They are not (explicitly) closed from client as they should always remain open. Db connection string:

--user-db-uri = jdbc:mysql://xx.xx.xx.241/tigasedb?user=tigase_user&password=*****&useUnicode=true&characterEncoding=UTF8

my.cnf:

root@TDB:~# egrep "^[^#]." /etc/mysql/my.cnf 
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock
default-character-SET=utf8
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0
[mysqld]
user        = mysql
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
skip-external-locking
bind-address        = 0.0.0.0
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
myisam-recover         = BACKUP
query_cache_limit   = 1M
query_cache_size        = 16M
log_error                = /var/log/mysql/error.log
expire_logs_days    = 10
max_binlog_size         = 100M
init_connect='SET collation_connection = utf8_general_ci; SET NAMES utf8;'
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
[mysqldump]
quick
quote-names
max_allowed_packet  = 16M
[mysql]
[isamchk]
key_buffer      = 16M
!includedir /etc/mysql/conf.d/

And there are also lots of reports of

Caused by: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request

and

Caused by: java.sql.SQLException: Query execution was interrupted

What is going on here ? Thank you!

Get SHOW WARNINGS stacktrace after calling a LOAD DATA command through Connector/J (1 reply)

$
0
0
Hi,

Is there a way to retrieve the SHOW WARNINGS stacktrace after calling a LOAD DATA command through Connector/J? If you look at the method below, I'd like to to do something like the commented out part. Actually, I'd rather redirect it to a file on disk, like tee does, but can redirect it from here easily enough.

@Override
public final void importData( final SrcFile srcFile, final String filePath )
throws FileNotFoundException, IOException, SQLException{

Connection con=null;
Statement stmt=null;
InputStream is=null;
try{
con=this.mySqlConnection.getRawConnection();
stmt=(com.mysql.jdbc.Statement)con.createStatement();
is=new FileInputStream( filePath );
if( con.isServerLocal() )
stmt.setLocalInfileInputStream( is );
if( !stmt.execute( command ) ){
logger.error( '['+this.getClass().getName()+"] SQL command:"+command );
}
else if( logger.isDebugEnabled() )
logger.debug( '['+this.getClass().getName()+"] SQL command:"+command );
/*
final ResultSet rs=stmt.executeQuery( "SHOW WARNINGS;" );
logger.warn( '['+this.getClass().getName()+"] : SHOW WARNINGS" );
while( rs.next() ){
logger.warn( '['+this.getClass().getName()+"] :"+rs.getString(1) );
logger.warn( '['+this.getClass().getName()+"] :"+rs.getString(2) );
logger.warn( '['+this.getClass().getName()+"] :"+rs.getString(3) );
}
rs.close();
*/
}
catch( final FileNotFoundException e ){ throw e; }
catch( final SQLException e ){
logger.error( '['+this.getClass().getName()+"] SQL command:"+command );
throw e;
}
finally{
if( stmt!=null ) stmt.close();
if( con!=null ) con.close();
if( is!=null ) is.close();
}

Thank you,
Jack
Viewing all 884 articles
Browse latest View live


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