Making JDBC Query to database using code
Connection conn=null;
ResultSet rs1=null;
try
{
PreparedStatement ps1=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection( "jdbc:oracle:thin:@127.0.0.1:1521:XE", "system", "manager");
Statement stmt = conn.createStatement();
rs1= stmt.executeQuery("select SUBJECT from HR.SUBJECT ");
}
catch(SQLException e)
{
while((e = e.getNextException()) != null) out.println(e.getMessage() + "");
}
catch(ClassNotFoundException e)
{
}
Reading the ResultSet
while(rs1.next()){
String ComboBoxValue1=rs1.getString("SUBJECT") ;
}
catch(Exception exp){
out.println("exception in populating subjects");
}
0 comments:
Post a Comment
If You Are Asking Some Question On This Comment Then Click On Subscribe by email Link