package li;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class yan {
/**
* @param args
*/
public static void main(String[] args) {
//2.建立同数据库的连接
//url:统一资源定位符
String url="jdbc:oracle:thin:@10.25.84.126:1521:orcl";
String user="scott";
String password="tiger";
Connection con=null;
Statement st=null;
String sql="select * from DEPT";
String sql1="delete from USERTEST";
ResultSet rs=null;
PreparedStatement pst=null;
//1.加载驱动
try{
Class.forName("oracel.jdbc.driver.OracelDriver");
con = DriverManager.getConnection(url, user, password);
System.out.println("数据库连接成功!");
}catch (ClassNotFoundException e){
//TODO Auto-generated catch block
e.printStackTrace();
}catch(SQLException e){
//TODO Auto-generated catch block
e.printStackTrace();
}
}
jave学习第一节代码
最新推荐文章于 2024-07-21 10:59:30 发布