Results 1 to 5 of 5
  1. #1
    kkji is offline Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    0

    Default How to inserting records in ms-access database using console (command line)?

    Please provide pointer or sample code.

  2. #2
    joeyvitoro is offline Member
    Join Date
    Oct 2011
    Posts
    90
    Rep Power
    0

    Default Re: How to inserting records in ms-access database using console (command line)?

    I did a quick Google search and founf it quite easily...

  3. #3
    kkji is offline Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    0

    Default Re: How to inserting records in ms-access database using console (command line)?

    is that console based means fields are taken by console and after that inserted into db.

    can you provide a url based on your search for instance.

  4. #4
    kkji is offline Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    0

    Default Re: How to inserting records in ms-access database using console (command line)?

    I did the search but found hard coded field values by using statement. No where it is console based.

  5. #5
    kkji is offline Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    0

    Default Re: How to inserting records in ms-access database using console (command line)?

    first I am trying with my-sql
    code:
    import java.sql.*;
    import java.io.*;
    public class InsertValuesMysql1{
    public static void main(String[] args) throws IOException {

    Connection con = null;
    String url = "jdbc:mysql://localhost:3306/";
    String db = "jdbctutorial";
    String driver = "com.mysql.jdbc.Driver";
    try{
    Class.forName(driver);
    con = DriverManager.getConnection(url+db,"root","root");
    try{
    Statement st = con.createStatement();
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    System.out.println("enter employee Id");


    int id = Integer.parseInt(br.readLine());

    System.out.println (id);
    System.out.println("Enter a name.");
    String name1 = br.readLine();
    System.out.println (name1);
    int val = st.executeUpdate("INSERT employee VALUES("+id+","+ "'name1'" +")");

    System.out.println("1 row affected");
    }
    catch (SQLException s){
    System.out.println("SQL statement is not executed!");
    }
    }
    catch (Exception e){
    }
    }
    }
    ============
    In above code id i.e. int is getting inserted in table but
    name is coming as hardcoded as "name" is table.
    how input value of name variable can be inserted in table?

Similar Threads

  1. Access command-line arguments from another class
    By Dreaming in forum New To Java
    Replies: 8
    Last Post: 10-18-2011, 02:42 AM
  2. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  3. Replies: 2
    Last Post: 07-02-2010, 02:20 PM
  4. how to fetch 20,000 records from excel sheet & insert into access database using Java
    By santosh_tamse in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-22-2009, 10:24 AM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 12:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •