Hello,I am a fresh man to study the DB2.An error occured when I try to
Run a Java class.
Details of the Error:
Code:
--------------------
com.ibm.db2.jcc .b.SqlException :DB2 SQL error:SQLCODE:-204,SQLSTATE:42 704, SQLERRMC :DB2ADMIN.TEST
--------------------
Following is the source:
Code:
--------------------
/*
* JDB2.java
*
* Created on 2006
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
import java.sql.*;
public class JDB2{
//Create the main method
public static void main(String args[]){
//Load JDBC Driver
String Driver="com.ibm .db2.jcc.DB2Dri ver";
//Create the URL
String Url="jdbc:db2://localhost:50000/BD";
//Use the Class.forName
try{
Class.forName(D river).newInsta nce();
}catch (Exception e){
System.out.prin tln(e);
}
//Create Connection
System.out.prin tln("Conneting. ..");
try{
Connection conn=DriverMana ger.getConnecti on(Url,"db2admi n","830401") ;
Statement stmt=conn.creat eStatement();
ResultSet rs=stmt.execute Query("select * from test");
while(rs.next() ) {
int ID=rs.getInt("i d");
String NAME=rs.getStri ng("name");
System.out.prin tln("ID"+"\t\t" +"NAME");
System.out.prin tln(ID+"\t\t"+N AME);
}
}catch(SQLExcep tion sqle){
System.err.prin tln(sqle);
}
}
}
--------------------
--
TurboDisk
------------------------------------------------------------------------
TurboDisk's Profile:
http://www.dbtalk.net/m197
View this thread:
http://www.dbtalk.net/t300860