hello everyone..
I am trying to connect a simple application to Oracle XE database. But when I run this program , the else part of program is running. Can Anyone tell whether I hav ewritten the code correct or not.
import java.sql.*;
public class jbc
{
public static void main(String args[])
{
int i=0;
try
{
String str="SELECT * FROM adi";
Class.forName("sun.jdbc.odbc.JdbcOdbcdriver");
Connection con = DriverManager.getConnection("jdbc:odbc:bm","SYSTEM","monika");
System.out.println("Connection open");
Statement stmt=con.createStatement();
ResultSet rs= stmt.executeQuery(str);
System.out.println("first Name");
while(i<3)
{
rs.next();
String lname=rs.getString("name");
System.out.println(lname);
i++;
}
con.close();
}
catch(Exception ex)
{
System.out.println("error occurred");
System.out.println("Error:" +ex);
}
}
}