Java Operation Oracle Database (Scheduling Table, Inserted Data, Delete) Select Blog from LM20224

xiaoxiao2021-03-06  87

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 ​​"; 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 caupht *** / n");}}}

转载请注明原文地址:https://www.9cbs.com/read-107316.html

New Post(0)