The Artima Developer Community
Sponsored Link

Java Answers Forum
Need Help Please

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Manoo

Posts: 3
Nickname: manoo
Registered: Oct, 2002

Need Help Please Posted: Nov 22, 2002 10:47 AM
Reply to this message Reply
Advertisement
Hi,

I have a java class which selects the data from a table which is in ABC database and inserts the data into a table on another database .... And i am getting an error

"[IBM][CLI Driver] CLI0115E Invalid cursor state. SQLSTATE=24000"
- Any help will be highly appriciated .....

The code is ..
import java.lang.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class Testing {
Connection conn;
Connection Iconn;
public static final String DB_driver = "COM.ibm.db2.jdbc.app.DB2Driver";
public static final String DB_NAME = "jdbc:db2:MYDATABASE";
public static final String DB_USERNAME = "XXXXX";
public static final String DB_PASSWORD = "XXXXX";
public static final String JDBC_DRIVER = "COM.ibm.db2.jdbc.app.DB2Driver";
public static final String T_DB_URL = "jdbc:db2:staging";
public static final String T_DB_USERNAME = "XXXXXXX";
public static final String T_DB_PASSWORD = "XXXXXXX";
public void getDbConnection()
{
String driver = null;
try {
try{
Class.forName(DB_driver);
} catch(Exception driverexp){
}
conn = DriverManager.getConnection(DB_NAME,DB_USERNAME,DB_PASSWORD);
Iconn = DriverManager.getConnection(T_DB_URL,T_DB_USERNAME,T_DB_PASSWORD);
} catch (Exception e) {
System.out.println(""+e.getMessage());
}
}
public void closeDbConnection()
{
try {
conn.close();
Iconn.close();
} catch (Exception e) {

System.out.println("closeDbConnection() :"+e.getMessage());
}
}
public int ShowResult()
{
int returnvalue = 0;
Statement I_st;
Statement st;
String sql;
String sql1;
// Statement pstmt;

sql = "Select BANK_NO,APPL_CD from CONTACT";
sql1 = "Insert into AFS_DATA(BANK_NO,APPL_CD) VALUES(?,?) " ;
try{
getDbConnection();
st = conn.createStatement();
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rset = pstmt.executeQuery();
while (rset.next());// eptID = rset.getInt(1);
String BANKNO = rset.getString("BANK_NO");
String APPL_CD = rset.getString("APPL_CD");
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1, BANK_NO);
pstmt.setString(2, APPL_CD);
pstmt.executeUpdate();
rset.close();
pstmt.close();
} catch(Exception e){
System.out.println(""+e.getMessage());
}
return returnvalue;
}

public static void main(String[] args) {
Testing FirstTest = new Testing();
FirstTest.ShowResult();
System.out.println("trying to connect ");
FirstTest.closeDbConnection();
}
}

Thanks

Topic: to read a file rtf whit java Previous Topic   Next Topic Topic: arrays + random access files

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use