I am running the following method:
private static void bulkLoad() throws SQLException{
final Connection connection = DriverManager.getConnection(connectionURL);
final Statement s = connection.createStatement();
s.execute("LOAD DATA LOCAL INFILE 'LoadData.txt' INTO TABLE emails FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'");
}
But am inconsistently (sometimes I get it and sometimes I don't) getting this error:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 114,558 milliseconds ago. The last packet sent successfully to the server was 104,210 milliseconds 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:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:983)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3644)
at com.mysql.jdbc.MysqlIO.sendFileToServer(MysqlIO.java:3730)
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3030)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2280)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2546)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2504)
at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:840)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:740)
at SendEmailTools.bulkLoad(SendEmailTools.java:18)
at SendEmailTools.main(SendEmailTools.java:110)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
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.write(Unknown Source)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3625)
... 10 more
At first, I figured it may be a timeout issue, but I checked my wait_timeout and saw it is set to 28800, which should be more than enough time. Does anyone know what's wrong?
Related
We are masking Sybase database using a third party tool written in Java. I am getting below error intermittently while masking a table of Sybase database. If I just re-execute the batch, it works fine so being really difficult to reproduce.
2020-01-09 04:41:55.657 Thread:Table Name - Error executing select statement for update
2020-01-09 04:41:55.657 Error Executing Batch
java.sql.SQLException: JZ006: Caught IOException: java.net.SocketTimeoutException: Read timed
out use getCause() to see the error chain
at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(ErrorMessage.java:829)
at com.sybase.jdbc4.jdbc.ErrorMessage.raiseErrorCheckDead(ErrorMessage.java:1141)
at com.sybase.jdbc4.tds.Tds.handleIOE(Tds.java:5186)
at com.sybase.jdbc4.tds.Tds.handleIOE(Tds.java:5131)
at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:2921)
at com.sybase.jdbc4.tds.TdsCursor.fetch(TdsCursor.java:422)
at com.sybase.jdbc4.tds.TdsCursor.fetch(TdsCursor.java:351)
at com.sybase.jdbc4.jdbc.SybCursorResultSet.next(SybCursorResultSet.java:187)
at com.grid_tools.products.datamasker.SQLUpdate.batchPreparedMasking(SQLUpdate.java:2706)
at com.grid_tools.products.datamasker.SQLUpdate.run(SQLUpdate.java:5717)
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.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at com.sybase.jdbc4.timedio.RawDbio.reallyRead(RawDbio.java:322)
at com.sybase.jdbc4.timedio.Dbio.doRead(Dbio.java:253)
at com.sybase.jdbc4.timedio.InStreamMgr.readIfOwner(InStreamMgr.java:583)
at com.sybase.jdbc4.timedio.InStreamMgr.doRead(InStreamMgr.java:319)
at com.sybase.jdbc4.tds.TdsProtocolContext.getChunk(TdsProtocolContext.java:622)
at com.sybase.jdbc4.tds.PduInputFormatter.readPacket(PduInputFormatter.java:239)
at com.sybase.jdbc4.tds.PduInputFormatter.read(PduInputFormatter.java:72)
at com.sybase.jdbc4.tds.TdsInputStream.read(TdsInputStream.java:91)
at com.sybase.jdbc4.tds.TdsInputStream.readUnsignedByte(TdsInputStream.java:124)
at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:2879)
WHERE "row_id" = ?
This is because of network issue at your end.. Probably your internet is not sable there.
I'm trying to test a connection to Remedy using the Java API, i.e. arapi7604_build002.jar.
According to the documentation, 4100 is a common AR System server port: https://docs.bmc.com/docs/display/public/itsm81/Port+information, but this isn't working for me:
private ARServerUser server;
private RemedyJavaAPITest() {
server = new ARServerUser();
server.setServer("fqd.com");
server.setUser("userName");
server.setPassword("pass123");
server.setPort(???);
}
public static void main(String[] args) {
RemedyJavaAPITest test = new RemedyJavaAPITest();
test.connect();
test.cleanup();
}
Error:
Connecting to AR Server...
ERROR (90): Cannot establish a network connection to the AR System server; Connection timed out: connect fqdn.com:4100
at com.bmc.arsys.apitransport.ApiProxyJRpcBase.connectionTry(Unknown Source)
at com.bmc.arsys.api.ProxyJRpc.getRpcClient(Unknown Source)
at com.bmc.arsys.api.ProxyJRpc.<init>(Unknown Source)
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.bmc.arsys.apitransport.connection.b.a(Unknown Source)
at com.bmc.arsys.apitransport.connection.b.createProxy(Unknown Source)
at com.bmc.arsys.api.ProxyManager.createProxy(Unknown Source)
at com.bmc.arsys.api.ProxyPool.createProxy(Unknown Source)
at com.bmc.arsys.apitransport.connection.a.get(Unknown Source)
at com.bmc.arsys.apitransport.connection.c.getProxy(Unknown Source)
at com.bmc.arsys.api.PoolingProxyManager.getProxy(Unknown Source)
at com.bmc.arsys.apitransport.connection.c.getProxy(Unknown Source)
at com.bmc.arsys.api.ARServerUser.verifyUser(Unknown Source)
at RemedyJavaAPITest.connect(RemedyJavaAPITest.java:37)
at RemedyJavaAPITest.main(RemedyJavaAPITest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Usually the port in which AR Server is listening for incoming connections can be configured. Please get it confirmed with your Remedy Administrators/Developers Below are some of the points you should take care while doing this.
Make sure that the machine where AR server is installed is reachable from the machine where you are running your java program.
setServer() required hostname(anything) which will connect to your target machine(hostname should be a resolvable one)
If you are able to connect to host machine and port number is wrong, you would getting an error message which says 'Connection Refused'. But you are getting 'timed out', which usually means your connection request is not received any reply from the network. So confirm your host name.
3700 is also commonly used for AR Servers.
I am creating about 150 files of around 5MB sizes. Vertx file APIs gives an exception randomly after creating 10-15 files "failed to create a child event loop".
(I am using vertx3 and java8)
Below is my code snippet (After I get a callback then only I call the function again to create the next file. So, file creation is never concurrent):
Vertx.vertx().fileSystem().writeFile(filepath,
Buffer.buffer(dataList.toString()), result -> {
if (result.succeeded()) {
System.out.println("File written");
} else {
System.err.println("Oh oh ..." + result.cause());
}
lambda.callback();
});
Below is my exception stack trace:
java.lang.IllegalStateException: failed to create a child event loop
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:68)
at io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:49)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:61)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:52)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:132)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:126)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:122)
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:34)
at io.vertx.core.Vertx.vertx(Vertx.java:78)
at rc_datawarehouse.CsvToJsonChunkWriter.writeCsvChunkToFiles(CsvToJsonChunkWriter.java:73)
at rc_datawarehouse.CsvToJsonReadWrite.lambda$2(CsvToJsonReadWrite.java:119)
at rc_datawarehouse.CsvToJsonReadWrite$$Lambda$16/1470881859.handle(Unknown Source)
at io.vertx.core.file.impl.AsyncFileImpl.handleData(AsyncFileImpl.java:335)
at io.vertx.core.file.impl.AsyncFileImpl.lambda$doRead$285(AsyncFileImpl.java:320)
at io.vertx.core.file.impl.AsyncFileImpl$$Lambda$17/1067800899.handle(Unknown Source)
at io.vertx.core.file.impl.AsyncFileImpl$2.lambda$done$289(AsyncFileImpl.java:408)
at io.vertx.core.file.impl.AsyncFileImpl$2$$Lambda$18/1632681662.handle(Unknown Source)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$15(ContextImpl.java:314)
at io.vertx.core.impl.ContextImpl$$Lambda$5/1780132728.run(Unknown Source)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:357)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Unknown Source)
Caused by: io.netty.channel.ChannelException: failed to open a new selector
at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:128)
at io.netty.channel.nio.NioEventLoop.<init>(NioEventLoop.java:120)
at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:87)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:64)
... 22 more
Caused by: java.io.IOException: Unable to establish loopback connection
at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source)
at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.ch.PipeImpl.<init>(Unknown Source)
at sun.nio.ch.SelectorProviderImpl.openPipe(Unknown Source)
at java.nio.channels.Pipe.open(Unknown Source)
at sun.nio.ch.WindowsSelectorImpl.<init>(Unknown Source)
at sun.nio.ch.WindowsSelectorProvider.openSelector(Unknown Source)
at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:126)
... 25 more
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Unknown Source)
at sun.nio.ch.Net.connect(Unknown Source)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at java.nio.channels.SocketChannel.open(Unknown Source)
at sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(Unknown Source)
... 34 more
I got my answer from the forum here (Thanks Jez)
Vertx.vertx() is the culprit. It creates a new vertx every time leading to multiple eventloops which seems to be the problem.
I cached it in a variable, rather than using Vertx.vertx() every time and it worked
cachedVertx.fileSystem().writeFile(...)
I am new to the concept of OLAP DB.
Please excuse me if I missed out something in the Connection String.
I am trying to connect to connect to Microsoft Analysis Server(which is in different Domain) from my System.
While Connecting I am getting below Error.
Can you please let me know, what am I doing wrong?
I have executed the Steps Mentioned in :
https://msdn.microsoft.com/en-us/library/gg492140.aspx
and referred to the below link for connection to the Cube:
http://www.matthewgodding.com/articles/2010/2/27/getting-data-from-sql-analysis-services-using-java-and-olap4.html
After connecting to the CUbe, I need to execute MDX Query.
Please find the snippet of the code I am using:
public static void main(String[] args) {
try {
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
final Connection connection = DriverManager
.getConnection("jdbc:xmla:Server=http://Remote_Server_IPAddress/OLAP/msmdpump.dll;"
+ "Catalog=MyCatalog;"
+ "User='Domian\\Username';" \\ This is the Username to login to the Server
+ "Password='Password';" \\ This is the Password to login to the Server
+ "Cube=Cube;"); \\This is the Cube Name
I get the below Exception when I execute the program:
Exception:
java.lang.RuntimeException: org.olap4j.OlapException: This connection encountered an exception while executing a query.
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:96)
at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:116)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapDatabase(XmlaOlap4jConnection.java:451)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getDatabase(XmlaOlap4jConnection.java:444)
at org.sid.practise.CheckConnection.main(CheckConnection.java:79)
Caused by: org.olap4j.OlapException: This connection encountered an exception while executing a query.
at org.olap4j.driver.xmla.XmlaHelper.createException(XmlaHelper.java:43)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:878)
at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getMetadata(XmlaOlap4jDatabaseMetaData.java:137)
at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getMetadata(XmlaOlap4jDatabaseMetaData.java:67)
at org.olap4j.driver.xmla.XmlaOlap4jDatabaseMetaData.getDatabaseProperties(XmlaOlap4jDatabaseMetaData.java:1044)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.makeConnectionPropertyList(XmlaOlap4jConnection.java:324)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.generateRequest(XmlaOlap4jConnection.java:1037)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:849)
at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:136)
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:90)
... 4 more
Caused by: org.olap4j.driver.xmla.proxy.XmlaOlap4jProxyException: This proxy encountered an exception while processing the query.
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.getResponse(XmlaOlap4jHttpProxy.java:181)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jAbstractHttpProxy.get(XmlaOlap4jAbstractHttpProxy.java:181)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.get(XmlaOlap4jHttpProxy.java:42)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:876)
... 12 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.getResponse(XmlaOlap4jHttpProxy.java:136)
It's difficult to know what went wrong for you. Few things you could do,
Don't specify cube in connection. This is not listed as property in XMLA driver.
You can install fiddler and see what's going on with the requests.
Not sure if single quotes are needed in user name and password.
I wrote this program to connect with my database which is on the same computer but i found a net connection error each time. com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
import java.sql.*;
public class Demo {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/db","username","pwd");
Statement stmt = connection.createStatement();
String str="SHOW TABLES";
ResultSet resultSet=stmt.executeQuery(str);
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
}
}catch(Exception e){
e.printStackTrace();
}
}
}
My Stacktrace is:-
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.ConnectException
MESSAGE: Connection refused: connect
STACKTRACE:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Demo.main(Demo.java:8)
** END NESTED EXCEPTION **
Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2847)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Demo.main(Demo.java:8)
Try this:
DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname","username","password");
If this is not sorted out go to where you installed Mysql and open MySQL Notifier and check server is running or not if not start it and then try executing your program.
This error was mainly due to Mysql server not reachable or not running. Check with below points:
1. Check your DB Connection whether MYSQL is up and running.
2. Check if you are able to connect from command prompt
3. Restart the mysql server and try again.