family公益广告,罗永浩 手机,王小雨
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 you do
}
rs.close();
ps.close();
}
public static void main(string[] args)
{
oraclejdbctest test = new oraclejdbctest();
test.init();
test.fetch();
}
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论