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 MYFIRST" + "(id INT,name CHAR(10))"; String sql="insert into MYFIRST values(''''1'''',''''liming'''')"; String sql1="insert into MYFIRST values(''''2'''',''''mm'''')"; String sql2="delete MYFIRST where id=2"; try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection(url, "test", "test"); Statement stmt = conn.createStatement(); stmt.executeUpdate(query); stmt.executeUpdate(sql); stmt.executeUpdate(sql1); stmt.executeUpdate(sql2); 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"); }}}
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18