Copy Code code as follows:
public class Oraclejdbctest
{
String Driverclass = "Oracle.jdbc.driver.OracleDriver";
Connection con;
public void init (FileInputStream fs) throws ClassNotFoundException, SQLException, FileNotFoundException, IOException
{
Properties Props = new properties ();
Props.load (FS);
String url = props.getproperty ("Db.url");
String userName = Props.getproperty ("Db.user");
String Password = props.getproperty ("Db.password");
Class.forName (Driverclass);
Con=drivermanager.getconnection (URL, userName, password);
}
public void Fetch () throws SQLException, IOException
{
PreparedStatement PS = con.preparestatement ("Select Sysdate from Dual");
ResultSet rs = Ps.executequery ();
while (Rs.next ())
{
Do the Thing
}
Rs.close ();
Ps.close ();
}
public static void Main (string[] args)
{
Oraclejdbctest test = new Oraclejdbctest ();
Test.init ();
Test.fetch ();
}
}