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 2 of 2

Thread: Inserting into database through swing

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Inserting into database through swing

    Hi,

    I am trying to insert data into database throgh swing. I am able to connect to database but while executing the query I am getting sql exception.

    My code is as follow.

    String sql="INSERT INTO student(StudentID,Name,Address,FName,Sex,DOB,Branc h) "
    + "VALUES ('"+tfsid+"','"+tffname.getText()+"','"+taadd.getT ext()+"','"+tflname.getText()+"','"+tfgender.getTe xt()+"',"
    + "'"+tfdob+"','"+tfbranch.getText()+"')";
    System.out.println("sql insert statement");

    stmt.executeUpdate(sql);

    I cant see any syntax error in the above statement.
    Any help appreciated

    Thanks!!!!
    Last edited by learn_java; November 6th, 2012 at 01:10 PM.


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Inserting into database through swing

    Please see the announcements page for the use of code tags.

    Any time you have an error please post the error message with your question. Error messages have this bad habit of telling what is wrong, and with that we can more easily help you

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

    learn_java (November 7th, 2012)

Similar Threads

  1. urgent inserting database in a java project
    By kavneetrekhi in forum JDBC & Databases
    Replies: 1
    Last Post: October 19th, 2012, 08:11 PM
  2. Inserting Large XML file into Oracle Database through java
    By hari_582 in forum JDBC & Databases
    Replies: 4
    Last Post: April 15th, 2012, 06:49 AM
  3. Inserting Large XML file into Oracle Database through java
    By hari_582 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 15th, 2012, 03:41 AM
  4. [SOLVED] Inserting date into database
    By mithcool in forum Java Theory & Questions
    Replies: 2
    Last Post: July 16th, 2011, 01:54 AM
  5. Check for duplicates before inserting into database
    By igor0203 in forum JDBC & Databases
    Replies: 1
    Last Post: December 2nd, 2010, 09:04 AM