java在Oracle中建表
类别: JAVA教程
import java.net.URL;
import java.sql.*;
public class Create {
public Create() {
}
public static void main(String[] args){
String url = "jdbc:oracle:thin:@10.0.1.3:1521:SDCDB";
String query = "CREATE TABLE testTable" + "(id INT,name CHAR(10))";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url, "test", "test");
Statement stmt = conn.createStatement();
stmt.executeUpdate(query);
System.out.println("Create Success!");
stmt.close();
conn.close();
}
catch(java.lang.ClassNotFoundException e){
System.err.print(e.getMessage());}
catch(SQLException ex){
System.out.println("/n***SQLException caught ***/n");
}
}
}
import java.sql.*;
public class Create {
public Create() {
}
public static void main(String[] args){
String url = "jdbc:oracle:thin:@10.0.1.3:1521:SDCDB";
String query = "CREATE TABLE testTable" + "(id INT,name CHAR(10))";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url, "test", "test");
Statement stmt = conn.createStatement();
stmt.executeUpdate(query);
System.out.println("Create Success!");
stmt.close();
conn.close();
}
catch(java.lang.ClassNotFoundException e){
System.err.print(e.getMessage());}
catch(SQLException ex){
System.out.println("/n***SQLException caught ***/n");
}
}
}
- 上一篇: java连接Oracle数据库
- 下一篇: Java是传值还是传引用
-= 资 源 教 程 =-
文 章 搜 索