Results 1 to 3 of 3

Thread: JDBC connectivity

  1. #1
    Harry Crosby is offline Member
    Join Date
    Sep 2009
    Posts
    61
    Rep Power
    3

    Default JDBC connectivity

    I am learning JAVA programming language. How can we get the details for printing the user’s details at run time using JDBC connectivity? Anybody knows any suitable code for that? Please reply me as soon as possible.

  2. #2
    ricky.black is offline Junior Member
    Join Date
    Feb 2010
    Posts
    24
    Rep Power
    0

    Default

    Here is the coding for JDBC Connectivity to retrieve users details:
    Code:
    import java.sql.*;
    import java.io.*;
    
    public class JDBCConnection 
    {
        
        public static void main(String args[])
        {
    		Connection conn;
    		Statement stmt;
    		ResultSet rs;
    		try
    		{
    			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    		}
    		catch(Exception e)
    		{
    			e.printStackTrace();
    		}
    
    		try
    		{
    		
    conn=DriverManager.getConnection("jdbc:odbc:employeedsn");
                            
    			stmt=conn.createStatement();
                            
    			rs=stmt.executeQuery("select * from emp"); 
                            System.out.println("EId   Ename    DOB  Dept       
    Salaryn");
    			while(rs.next())
    			{
                               
    System.out.println(+rs.getInt(1)+"          
    "+rs.getString(2)+"            "+rs.getString(3)+"        
    "+rs.getString(4)+"         "+rs.getInt(5));
    				
    			}
    			stmt.close();
    			conn.close();
    		}
    
    		catch(Exception e)
    		{
    			e.printStackTrace();
    		}
    	}
    }

  3. #3
    Join Date
    Feb 2010
    Posts
    46
    Rep Power
    0

    Default

    Try this:
    Code:
    import java.sql.*;
    import java.io.*;
    public class Employeedetails
    {
     public static void main(String args[])
     {
      try 
       {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employeeds");
    Statement st=con.createStatement();
    ResuleSet rs=st.executeQuery("select * from emp");
    System.out.println("EId  Ename  Salaryn");
    while(rs.next())
    {                          
    System.out.println(+rs.getInt(1)+"          
    "+rs.getString(2)+"            "+rs.getString(3));
    				
    }
    			st.close();
                         	con.close();
    }
    catch(Exception e)
    		{
    			e.printStackTrace();
    		}
    
     }
    }

Similar Threads

  1. IP conflict and no connectivity on one or all
    By annet56 in forum Networking Jargons
    Replies: 0
    Last Post: 10-14-2009, 06:35 PM
  2. Server connectivity
    By bunnut78 in forum General Internet Terms
    Replies: 0
    Last Post: 04-08-2009, 05:51 AM
  3. Internet connectivity
    By bunnut78 in forum General Internet Terms
    Replies: 0
    Last Post: 04-08-2009, 05:42 AM
  4. Connectivity ports
    By enrich444 in forum General Internet Terms
    Replies: 0
    Last Post: 12-01-2008, 08:06 AM
  5. Connectivity
    By techpro in forum General Internet Terms
    Replies: 0
    Last Post: 04-03-2008, 09:20 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48