Home > Database > Mysql Tutorial > java连接oracle 跟 mysql 的例子

java连接oracle 跟 mysql 的例子

WBOY
Release: 2016-06-07 16:23:47
Original
1104 people have browsed it

java连接oracle 和 mysql 的例子 @Test public void oravleDemo() throws Exception { Class.forName("oracle.jdbc.driver.OracleDriver"); String url = "jdbc:oracle:thin:@localhost:1521:库名"; Connection conn = DriverManager.getConnection(url, "use

java连接oracle 和 mysql 的例子
@Test
public void oravleDemo() throws Exception {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String url = "jdbc:oracle:thin:@localhost:1521:库名";
    Connection conn = DriverManager.getConnection(url, "username", "password");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from SO_T_ENTERPRISE Where SE_I_ID = " );
    while (rs.next()) {
    rs.getString("字段名");
    }
            conn.close();
}


@Test
public void oravleDemo() throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    String url = "jdbc:mysql://localhost:3306/库名";
    Connection conn = DriverManager.getConnection(url, "username", "password");
    Statement stmt = conn.createStatement();
    String sqlparse ="insert into tablr(id) values (1)";
    stmt.execute(sqlparse);
            conn.close();
}
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