You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@trafodion.apache.org by "Yang, Peng-Peng" <pe...@esgyn.cn> on 2017/12/01 13:01:50 UTC

How to set connection idle timeput in MXOSRVR side?

Hi Trafodioneers,

Do we have a way to set connection idle timeout in MXOSRVR side?

When I use JDBC program to access trafodion(2.3),  I suffered this error.
------------------------------------------------------------------------
2017-12-01 04:29:11
2017-12-01 04:30:11
2017-12-01 04:35:11
2017-12-01 04:45:11
2017-12-01 05:00:11
Exception in thread "main" org.trafodion.jdbc.t4.TrafT4Exception: Server aborted abnormally or Connection timed out
       at org.trafodion.jdbc.t4.TrafT4Messages.createSQLException(TrafT4Messages.java:284)
       at org.trafodion.jdbc.t4.InputOutput.doIO(InputOutput.java:460)
       at org.trafodion.jdbc.t4.T4Connection.getReadBuffer(T4Connection.java:162)
       at org.trafodion.jdbc.t4.T4Statement.getReadBuffer(T4Statement.java:196)
       at org.trafodion.jdbc.t4.T4Statement.Close(T4Statement.java:164)
       at org.trafodion.jdbc.t4.InterfaceStatement.close(InterfaceStatement.java:1147)
       at org.trafodion.jdbc.t4.TrafT4Statement.close(TrafT4Statement.java:161)
       at testjdbc.TestJDBC.main(TestJDBC.java:76)
------------------------------------------------------------------------


JDBC program .
---------------------------------------------------------------------------
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import javax.xml.crypto.Data;

public class TestJDBC {
       protected static String url = "jdbc:t4jdbc://ip:23400/:";
       protected static String driverClass = "org.trafodion.jdbc.t4.T4Driver";
       protected static String userName = "username";
       protected static String pwd = "passwd";

       protected static Connection conn;

       public static void main(String[] args) throws Exception {
              Class.forName(driverClass);
              PreparedStatement ps = null;
              Statement stmt = null;
              try {
                     long startconnTime = System.currentTimeMillis();
                     conn = DriverManager.getConnection(url, userName, pwd);
//                   String sql = "select * from seabase.test001";
                     String sql = "insert into t002 values(11, 'ddfgh11')";
                     String sql2 = "insert into t002 values(22, 'ddfgh22')";
                     String sql3 = "insert into t002 values(33, 'ddfgh23')";
                     String sql4 = "insert into t002 values(44, 'ddfgh24')";
                     String sql5 = "insert into t002 values(55, 'ddfgh25')";
                     String sql6 = "insert into t002 values(66, 'ddfgh26')";
                     String sql7 = "insert into t002 values(77, 'ddfgh27')";
//                   String sql = "select * from dual";
//                   ps = conn.prepareStatement(sql;)
                     stmt = conn.createStatement();
                     stmt.setQueryTimeout(10);
//                   ResultSet rs = stmt.executeQuery(sql);
//                   while(rs.next()) {
//                          System.out.println(rs.getInt(1) + "========" + rs.getString(2));
//                   }
                     System.out.println("star//////");
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql);
                     TimeUnit.MINUTES.sleep(1);
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql2);
                     TimeUnit.MINUTES.sleep(5);
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql3);
                     TimeUnit.MINUTES.sleep(10);
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql4);
                     TimeUnit.MINUTES.sleep(15);
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql5);
                     TimeUnit.MINUTES.sleep(20);
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql6);
                     TimeUnit.MINUTES.sleep(25);
                     System.out.println(new SimpleDateFormat("YYYY-MM-dd hh:mm:ss").format(new Date()));
                     stmt.execute(sql7);
                     long endconnTime = System.currentTimeMillis();
                     System.out.println((endconnTime - startconnTime) + " milliseconds totally to logon.");

              } finally {
                     if (ps != null) {
                            ps.close();
                     }
                     if(stmt != null) {
                            stmt.close();
                     }
                     if (conn != null) {
                            conn.close();
                     }
              }

       }

}
---------------------------------------------------------------------------

Regards,
Pengpeng