Chinaunix首页 | 论坛 | 博客
  • 博客访问: 67732
  • 博文数量: 27
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 509
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-08 13:35
文章分类
文章存档

2013年(27)

我的朋友

分类: Java

2013-12-15 13:49:11

----db.properties--------

dbDriver = oracle.jdbc.driver.OracleDriver
url = jdbc:oracle:thin:@192.168.1.186:1521:jfglorcl
userName=jfgl
password=jfgl

 

------------  JDBConnection  ----------------------------

public class JDBConnection {
public Connection connection = null;
public JDBConnection() {
ResourceBundle bundle = ResourceBundle.getBundle("db"); 
String driver = bundle.getString("dbDriver"); 
String url = bundle.getString("url"); 
String user = bundle.getString("userName"); 
String password = bundle.getString("password"); 
try {bet4584.com/
Class.forName(driver).newInstance();
connection = DriverManager.getConnection(url, user, password);
} catch (ClassNotFoundException e) { 
System.out.println(e.toString());
System.out.println("数据库加载失败");
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
bet2431.com/
}

--------------------------xxxDao---------------

public class xxxDao {
private Connection connection = null; //定义连接的对象
private PreparedStatement ps = null; //定义预准备的对象
private JDBConnection jdbc = null; //定义数据库连接对象
public jfljDao() {
jdbc = new JDBConnection();
connection = jdbc.connection; //利用构造方法取得数据库连接
}
public void xx(){
String sql="xxxx";
try {ylc5426.com/
ps = connection.prepareStatement(sql);
ps.executeUpdate();
ps.close();
}
catch (SQLException ex) {
}
}

}
技术参考:bet7568.com/

阅读(1207) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~