Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import java.lang.*;
import java.io.*;
import COM.ibm.db2.jdbc.app.*;
public class Type2ExampleLegacy {
public static void main(String[] args)
{
try
{
// load the DB2 Driver
Class.forName("com.ibm.db2.jcc.DB2Driver");
//Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
// establish a connection to DB2
Connection db2Conn = DriverManager.getConnection("jdbc:db2://localhost:50000/DAS","root","root");
// use a statement to gather data from the database
Statement st = db2Conn.createStatement();
String myQuery = "select * from NAME";
// execute the query
ResultSet resultSet = st.executeQuery(myQuery);
// cycle through the resulSet and display what was grabbed
/*while (resultSet.next())
{
String LASTNAME = resultSet.getString("LASTNAME");
//String phoneNumber = resultSet.getString("phonenumber");
System.out.println(LASTNAME);
//System.out.println("Phone Number: " + phoneNumber);
//System.out.println("-------------------------------");
}
// clean up resources*/
System.out.print("das");
resultSet.close();
st.close();
db2Conn.close();
}
catch (ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
}
}
this is ma code ,when i run it got some errors
com.ibm.db2.jcc.am.ro: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704,
at com.ibm.db2.jcc.am.ed.a(ed.java:676)
at com.ibm.db2.jcc.am.ed.a(ed.java:60)
at com.ibm.db2.jcc.am.ed.a(ed.java:127)
at com.ibm.db2.jcc.am.tm.c(tm.java:2523)
at com.ibm.db2.jcc.am.tm.d(tm.java:2511)
at com.ibm.db2.jcc.am.tm.a(tm.java:1991)
at com.ibm.db2.jcc.t4.fb.g(fb.java:140)
at com.ibm.db2.jcc.t4.fb.a(fb.java:40)
at com.ibm.db2.jcc.t4.t.a(t.java:32)
at com.ibm.db2.jcc.t4.ub.i(ub.java:135)
at com.ibm.db2.jcc.am.tm.fb(tm.java:1962)
at com.ibm.db2.jcc.am.tm.a(tm.java:2981)
at com.ibm.db2.jcc.am.tm.a(tm.java:652)
at com.ibm.db2.jcc.am.tm.executeQuery(tm.java:636)
at Type2ExampleLegacy.main(Type2ExampleLegacy.java:27 )
using windows xp sp2
plzzzzzzz help me
