getConnection(String url);
getConnection(String url, String username, String password);
getConnection(String url, Properties Info);
ResultSet rs = stmt.executeQuery("select * from students");
while (rs.next())
{
System.out.println (rs.getInt(1)+" "+rs.getString(2)+" "+rs.getFloat(3));
}
import java.sql.*;
class JDBCDemo
{
public static void main(String args[])
{
try
{
//Load the driver
Class.forName("oracle.jdbc.driver.OracleDriver");
//Cretae the connection object
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott", "tiger");
//Create the Statement Object
Statement stmt = con.createStatement();
//Excute the SQL query
ResultSet rs = stmt.executeQuery("Select * from students");
while (rs.next())
{
System.out.println (rs.getInt(1)+" "+rs.getString(2)+" "+rs.getFloat(3));
}
//Closing the connection object
con.close();
stmt.close();
rs.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}