Closed Thread
Results 1 to 6 of 6

Thread: connection between JAVA & SQL SERVER

  1. #1
    mkcit is offline Newbie
    Join Date
    Mar 2007
    Posts
    2
    Rep Power
    0

    connection between JAVA & SQL SERVER

    Please members , i need to help me ..

    now i'm establishing my graduate project, and i'm useing java programming language,and sql server to implement the application, but i face problem, that i don't know how i can connect java with sql server.

    so i hope from you to help me please, and if possible explain that step by step, and support that by simple pictures, becuase these steps is very necessary for me.
    note : i download JDBC driver from microsoft web site for connection, and attempt by simple tests to make connection but i failed.

    THANKS FOREVER
    Last edited by mkcit; 03-24-2007 at 03:00 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    This is the code for connecting to a mysql server that I made for another post

    Code:
    package net.codecall.forums.general;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    public class MySqlConnect {
    
    	public static void main(String args[]) {
    		Connection con = null;
    		String dbname = "";
    		String dbuname = "";
    		String dbpassword = "";
    
    		try {
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    			con = DriverManager.getConnection("jdbc:mysql:///" + dbname, dbuname, dbpassword);
    
    			if(!con.isClosed()){
    				System.out.println("Successfully connected to " + dbname);
    			}
    		} catch(Exception e) {
    			System.err.println("Exception: " + e.getMessage());
    		} finally {
    			try {
    				if(con != null){
    					con.close();
    				}
    			} catch(SQLException e) {}
    		}
    	}
    }

  4. #3
    mkcit is offline Newbie
    Join Date
    Mar 2007
    Posts
    2
    Rep Power
    0
    Thanks Mr Sidewinder for code, but in fact i want the way to connect by sql server.

  5. #4
    SNK111 is offline Newbie
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Re: connection between JAVA & SQL SERVER

    Check this article HOW TO: SQL in JAVA for details on how to connect to SQL Server database from C#.NET database applications as well as Java database applications. It also describes how to pass embedded SQL queries (SELECT, INSERT, UPDATE, DELETE), calling stored procedures, pass parameters etc.

    Shahriar Nour Khondokar

  6. #5
    GMVResources's Avatar
    GMVResources is offline Learning Programmer
    Join Date
    Jun 2010
    Posts
    72
    Rep Power
    0

    Re: connection between JAVA & SQL SERVER

    Maybe if it still doesn't work use a different server

  7. #6
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: connection between JAVA & SQL SERVER

    This is a three year old thread!
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. Replies: 1
    Last Post: 02-10-2011, 02:09 AM
  2. Client-Server Connection
    By Apprentice123 in forum C and C++
    Replies: 4
    Last Post: 10-28-2010, 12:35 PM
  3. Replies: 15
    Last Post: 10-12-2010, 05:23 PM
  4. mysql server - connection problem
    By cinek in forum Visual Basic Programming
    Replies: 5
    Last Post: 01-30-2009, 08:23 AM

Tags for this Thread

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