-
ibeautiful
class.forname("oracle.jdbc.driver.OracleDriver");//加载数据库驱动String url="jdbc:oracle:thin:@localhost:1521:db_name";String sql="CREATE TABLE table(filed1 varchar2(2),filed2 varchar2(2))";Connection conn=DriverManager.getConnection(url,"scott","tiger");//建立数据库连接if(!conn.isClose()){Statement stmt = conn.createStatement();stmt.executeUPDATE(sql); //建立一个表}
-
湖上湖
Class.forName("com.mysql.jdbc.Driver");Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");String sql = "CREATE TABLE tableName (id int not null, name varchar(20) not null, age int null, primary key (id));";PreparedStatement pstmt = conn.prepareStatement(sql);pstmt.executeUpdate();
-
蛊毒传说
use mysql;create table student(id number,name varchar(20),age number);