database - How to read file line by line and put it into orcale db -
This is my file that I want to read: - My standalone program is like this .. In this code I want to read the line from my drive line and insert the row in the line in Oracle DB. Please correct my code or suggest a new idea. Thanks in advance I think SD is a binary format, if you want to play it later - You should store entire SD content in a blob / secure file or something like that
20140901 | 2X-PRG-CZ | PRG | 2x | 2x-PRG-CGD || TIPX || QXXXX | QS | QS-PRG-GW | PRG | TEPB | Y 2 | 98 | 0 | 0 0 0 0 9 0 | 2x-PRG-CZ PRG | 2x | 2X-PRG-CZ ||| TAEPX || QXtxGx | OK. OK-PRG-MQ | PRG | TEPB | Y 14 | 672 | 0 | 0 0 0 001 | 2x-PRG-CZ PRG | 2x | 2xpg-cz ||| TAPX || QXtxGx | EK | EK-PRG-KK | PRG | TEPB | Y 1 | 48 | 0 | 0 0 0 9 01 | Xs-esin-ol | MAD | 3v | 3 V-MAD-OO ||| STXOL || QXTXGXS | 7x | 7X-BRU-EP | BRU | TYPEB | Y | 1 | 59 | 0 | 0 20,140,901 XS-SIN-OL | MAD | 3V | 3V-MAD-OO ||| STXOL || QXTXGXS | 3v | 3v-lgg-sp. LGG | TEEPB | Y 1 | 193 | 0 | 0 0 0 001 | XS-SIN-OL | MAD | 3v | 3 V-MAD-OO ||| STXOL || QXtxGx | 7x | 7X-PAR-EP | Equal TYPEB | Y | 1 | 59 | 0 | 0 20,140,901 XS-SIN-OL | MAD | 3V | 3V-MAD-OO ||| STXOL || QXTXGXS | YA | Ya-MAD-GS | MAD | TYPEB | Y | 4 | 923 | 0 | 0
package com.dbConn; Import java.io.buffferedReader; Import java.io.file; Import java.io.FileInputStream; Import java.io.fileReader; Import java.io.InputStream; Import java.sql.Connection; Import java.sql.DriverManager; Import java.sql.PreparedStatement; Public class DbConnection {public static zero main (string [] args) {int updateQuery = 0; {Try DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ()); System.out.println ("Connecting to the database ..."); Connection Connection = DriverManager.getConnection ("JDBC: Oracle: Slim: @ 124.18.10.22: 1521: INT9", "Nitin", "Nitin"); String filePath = "D: /ishan1/R3AP201409_GMSTYXCODG_00740_20140902024214.SND"; InputStream inputstream = new FileInputStream (new file (filePath)); System.out.println ("Inputstream:" + inputstream.stosting ()); String name = "Hamilton"; String email = "fred@abc.com"; String str = inputStream.toString (); String sql = "EXT_SITATEXT_ONLINE_ERROR INSERT (SERVICE_ID, USAGE_DATA, FILE_NAME_LINE_NUMBER) value (?,?,?)"; Statement made = connection. Preprestamentation (SKL); Try (BufferedReader br = new BufferedReader (New FileReader (filepath)) {{string line, (line = br.readLine ()) = null;;) {println (line); }} Statement.setString (1, name); Statement.setString (2, str); Statement.setString (3, email); Statement.executeUpdate (); UpdateQuery = statement.executeUpdate (SQL); If (updateQuery! = 0) {System.out.println ("The table is successfully created and the" + updateQuery + "is included in the row.); } Int row = statement.executeUpdate (filePath); If (line & gt; 0) {System.out.println ("contact was inserted."); } Statement.close (); Connection.close (); } Hold (exception e) {System.out.println ("exception is raised:" + E); }}}
Comments
Post a Comment