Alguém sabe como faço pra resolver esse problema? O servidor do banco esta no ar, pois consigo acessa-lo através de um front que peguei pra db2, no entanto quando tento no meu programa ele da essa exeção:
COM.ibm.db2.jdbc.DB2Exception: [IBM][Controlador JDBC] CLI0615E Erro durante recepção do soquete, o servidor não está respondendo. SQLSTATE=08S01
at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.throwReceiveError(SQLExceptionGenerator.java:447)
at COM.ibm.db2.jdbc.net.DB2Request.receive(DB2Request.java:703)
at COM.ibm.db2.jdbc.net.DB2Request.sendAndRecv(DB2Request.java:563)
at COM.ibm.db2.jdbc.net.DB2Connection.SQLConnect(DB2Connection.java:328)
at COM.ibm.db2.jdbc.net.DB2Connection.SQLConnect(DB2Connection.java:290)
at COM.ibm.db2.jdbc.net.DB2Connection.create(DB2Connection.java:275)
at COM.ibm.db2.jdbc.net.DB2Connection.(DB2Connection.java:200)
at COM.ibm.db2.jdbc.net.DB2Driver.connect(DB2Driver.java:215)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Main.main(Main.java:22)
O problema deve estar na sua classe de conexão com o banco de dados… Tem como postar ela aqui para nós darmos uma olhada?!
Encontrei um exemplo da própria IBM, segue abaixo…
//
// Source File Name: Tools.java 1.3
//
// Licensed Materials -- Property of IBM
//
// (c) Copyright International Business Machines Corporation, 1999.
// All Rights Reserved.
//
// US Government Users Restricted Rights -
// Use, duplication or disclosure restricted by
// GSA ADP Schedule Contract with IBM Corp.
//
// This is a toolkit for DB2 Java program samples.
//
import java.io.*;
import java.lang.*;
import java.sql.*;
class Tools {
static {
try {
// register the driver with DriverManager
// The newInstance() call is needed for the sample to work with
// JDK 1.1.1 on OS/2, where the Class.forName() method does not
// run the static initializer. For other JDKs, the newInstance
// call can be omitted.
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
//
// DBConnect
// - if provided with database name, user ID, and password,
// connects to database
// - otherwise prompts user for database name, user ID, and
// password and connects to database
// - returns the connection
//
public static Connection DBConnect(String dbname, String uid, String pwd)
{
Connection con = null;
try {
String url;
// URL is jdbc:db2:dbname
url = "jdbc:db2:" + dbname;
// connect with id and password
con = DriverManager.getConnection(url, uid, pwd);
System.out.println (">Connected to " + dbname);
} catch (Exception e) { e.printStackTrace(); }
return con;
}
// prompt for database, user id, and password
public static Connection DBConnect()
{
Connection con = null;
try {
String dbname, url, uid, pwd;
System.out.println (">Enter Database Name:");
dbname = readString();
System.out.println (">Enter User Name:");
uid = readString();
System.out.println (">Enter Password:");
pwd = readString();
// URL is jdbc:db2:dbname
url = "jdbc:db2:" + dbname;
// connect with id and password
con = DriverManager.getConnection(url, uid, pwd);
} catch (Exception e) { e.printStackTrace(); }
return con;
}
//
// readString
// - declares the input stream to be the system.in and reads in
// - a string - returns this such string
//
public static String readString() {
try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String r = br.readLine();
return r;
}
catch( IOException e) { return ""; }
}
//
// padLength
// - adds spaces to input on the right to make n chars long
// = keeps the string on the left of the output string
//
public static String padLength(String input, int n) {
try {
while (input.length() < n) { input = input + " "; }
return input;
}
catch( Exception e) { return ""; }
}
//
// padLengthRight
// - adds spaces to input on the left to make n chars long
// - the new string has the old string on the utmost right
//
public static String padLengthRight(String input, int n) {
try {
while (input.length() < n) { input = " " + input; }
return input;
}
catch( Exception e) { return ""; }
}
}