Auto-DB

zhaozj2021-02-16  53

Package SQL;

import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.sql.Connection; import java.sql.DriverManager Import java.sql.statement;

Public class createnesschema {

Public static void main (string [] args) throws Exception {// readschema (); createnesschema ();

Static void createnesschema () throws exception {

Class.Forname ("Oracle.jdbc.driver.OracleDriver"). NewInstance (); String Url = "JDBC: Oracle: Thin: @localhost: 1521: john; string user =" inqint "; string password =" inqint " ; Connection conn = DriverManager.getConnection (url, user, password); Statement stmt = conn.createStatement (); // String sql = new String (readSchema () getBytes ( "gb2312"), "ISO8859_1".); String sql = readContent (); string temp [] = SQL.Split (";"); for (int i = 0; i

}

static String readSchema () {StringBuffer content = new StringBuffer (); try {File file = new File ( "src / com / augmentum / inquira / setting / createTable.sql"); FileInputStream fin = new FileInputStream (file); FileChannel fc = fin.getchannel (); bytebuffer buffer = bytebuffer.allocate (new long (file.Length ()). INTVALUE ()); fc.read (buffer);

For (int i = 0; i

// system.out.println (content);} catch (exception e) {system.out.println ("Exception:" E.getMessage ());} Return Content.toString ();}

static String readContent () {String fc = null; try {File file = new File ( "src / com / augmentum / inquira / setting / createTable.sql"); BufferedInputStream bis = null; int remaining = (int) file.length (); Int offset = 0; int status = 0; byte rc [] = new byte [remaining]; bis = new buffutInputStream (New fileInputStream (file);

While (Remaining> 0 && (status = bisund (rc, offset, remaining)> = 0) {offset = status; remaining - = status;} fc = new string (rc);} catch (Exception E) {System.out.println ("Exception:" E.getMessage ());} Return FC;

}

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

New Post(0)