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