当前位置:Gxlcms > mysql > java连接oracle跟mysql的例子

java连接oracle跟mysql的例子

时间:2021-07-01 10:21:17 帮助过:17人阅读

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();
}

人气教程排行