Home > Database > Mysql Tutorial > oracle jdbc

oracle jdbc

WBOY
Release: 2016-06-07 15:13:08
Original
1376 people have browsed it

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 /** * @author:zhangzhengxing * @faction:Java连接Oracle * @time:2011.03.24 */ package oracle0; //怎么用JDBC_ODBC桥连接的方式连接数据库 import java.sql.*; public class TestOracle01 { pub

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

    /**

    * @author:zhangzhengxing

    * @faction:Java连接Oracle

    * @time:2011.03.24

    */

    package oracle0;

    //怎么用JDBC_ODBC桥连接的方式连接数据库

    import java.sql.*;

    public class TestOracle01 {

    public static void main(String[] args) {

    //首先考虑有异常

    try {

    //1.怎么加载驱动

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  //注意大小写

    //2.得到连接

    //jdbc:odbc:???(问号是数据源)

    Connection ct=DriverManager.getConnection("jdbc:odbc:myoracle","scott","ptyh");

    //3.下面跟sql server一样的

    Statement sm=ct.createStatement();

    ResultSet rs=sm.executeQuery("select * from emp");

    while(rs.next())

    {

    //用户名

    System.out.println("用户名是:"+rs.getString(2));

    }

    } catch (Exception e) {

    e.printStackTrace();

    }

    }

    }

oracle jdbc

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template