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 sql express using jdbc

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Inserting into sql express using jdbc

    I am trying to insert some data into my database using java and sql 2008 express and so i've downloaded the jar files I nedd from Download: Microsoft JDBC Driver 4.0 for SQL Server - Microsoft Download Center - Download Details and I went to my project and clicked on "Run">>>"Run Configurations">>>"CLASSPATH" >>>"Add External Jars" and I added the jar file RunConfigurations.jpg

    my code is as follows:

     
    import java.sql.*;
     
    public class Insertme {
     
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
     
     
    		 try { 
    	           /* String url = "jdbc:msql://200.210.220.1:1114/Demo"; */
    	            String url = "jdbc:sqljdbc4://WEIGHBRIDGE2-PC/sqlexpress/NewDB"; 
    	            Connection conn = DriverManager.getConnection(url,"",""); 
    	            Statement st = conn.createStatement(); 
    	           /*   st.executeUpdate("INSERT INTO MyNames " + 
    	                "VALUES (Talent, 'Simpson')");    */
     
    	            	            st.executeUpdate("INSERT INTO MyNames  VALUES ('Talent', 'Simpson')"); 
     
    	       	            conn.close(); 
    	        } catch (Exception e) { 
    	            System.err.println("Got an exception! "); 
    	            e.printStackTrace();
    	            /*System.err.println(e.getMessage()); */
     
     
    	}
     
    	}
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Inserting into sql express using jdbc

    Do you have a problem or a question?

Similar Threads

  1. Help with inserting into a b-tree
    By kari4848 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 10th, 2012, 12:40 PM
  2. JDBC Problem - com.mysql.jdbc.Driver
    By icu222much in forum Java Servlet
    Replies: 2
    Last Post: November 21st, 2011, 11:54 PM
  3. [SOLVED] inserting utf8 data into DB
    By serdar in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 5th, 2011, 05:21 PM
  4. [SOLVED] Inserting date into database
    By mithcool in forum Java Theory & Questions
    Replies: 2
    Last Post: July 16th, 2011, 01:54 AM
  5. Inserting Image Help
    By Bradshjo in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 22nd, 2010, 12:50 PM