1.注册加载一个Drvier驱动:
Class.forName("..........");
2.创建数据库连接
- String url="jdbc:oracle:thin:@172.16.0.6:1521:tangjl";
- String user="openlab";
- String password="open123";
- Connection Con=DriverManager.getConnection(url,user,password);
Jdbc:oracle:this:(协议)@xxx.xxx.xxx:xxx(ip地址及端口号):xxx(使用数据库名)
Mysql的url是jdbc:mysql://localhost:3306/test
3.获得一个statement对象(PreparedStatement)
- String sql="select * from a_yyy";
- Statement s=con.createStatment();