Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Insert into database from flat file

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    8
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Insert into database from flat file

    Hi, I am trying to insert the contents of a flat file into table. To connect to database i am using JDBC driver. I the problem i am facing is the contents of flat file is being inserted into table only for the first time when i run the program, again when i try to insert into it( even though table is empty) i am getting an error message.
    Can anyone help me in this regard.
    Thanks in advance.

    program to insert into table:
     
    public void doWork (String s) throws Exception{
     
    		    String [] ar = s.split("\\-");
    		    try{
    		      Class.forName("oracle.jdbc.driver.OracleDriver");
    		      con = DriverManager.getConnection(url,userName,password);
    		      String queryString = "INSERT INTO feeds ( subject,time,creator) values('"+ar[0]+"','"+ar[1]+"','"+ar[2]+"')"; 
     
    		      stmt=con.createStatement();
    		      val = stmt.executeUpdate(queryString);
     
    		    }
    		    catch(Exception e)
    		    {
    		      System.out.println("e : " + e);
    		    }
    	  }

    Error message I am getting again when i run the program:

    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    e : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    Last edited by HelloAll; March 10th, 2011 at 03:14 AM.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Insert into database from flat file

    Are you sure you have the JDBC driver installed correctly? It doesn't look like it can find it..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. The Following User Says Thank You to JavaPF For This Useful Post:

    HelloAll (March 10th, 2011)

  4. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    8
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Insert into database from flat file

    I had not included jdbc jar file... Thanks. Its working now.

Similar Threads

  1. how to import excel file to database table using java
    By palani in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: September 3rd, 2010, 12:17 AM
  2. insert(embed) a file object (.txt file) in MS excel sheet using java.
    By jyoti.dce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 12th, 2010, 08:16 AM
  3. Download File from Mysql database
    By Puk284 in forum Java Servlet
    Replies: 0
    Last Post: April 24th, 2010, 07:43 AM
  4. Replies: 1
    Last Post: January 15th, 2010, 01:32 AM
  5. Input file parsing to insert into DB
    By IDForums in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 30th, 2009, 02:29 AM