eclipse连接oracle数据库

来源:互联网 发布:if you十三国语言知乎 编辑:程序博客网 时间:2024/05/21 10:11

第一步:配置好oracle的环境变量

第二步把jar包导入到reference libraries

点击工程名build path->add external......

第三部具体代码

public class hello {
 @SuppressWarnings("unused")
 public static void main(String[] args) {
        System.out.println("Hello World!");

       
        String user="SYSTEM";
        String passwd="Zhuying123";
        String url="jdbc:oracle:thin:@localhost:1521:orcl";
        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
           Connection connection=DriverManager.getConnection(url, user, passwd);
            System.out.println("success");
        }catch (SQLException e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        catch (ClassNotFoundException e) {
            // TODO: handle exception
            e.printStackTrace();
        }
 }
}


0 0
原创粉丝点击