Results 1 to 1 of 1
  1. #1
    selomojemalo is offline Member
    Join Date
    May 2013
    Rep Power

    Default connect Java to ms sql server 2012

    first of all sorry for my english....

    im new in java and trying to connect on db but i getting this error: " on: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."."

    under sql server configuration manager tcp/ip is enabled, port is 1433, i tryed to disable firewall but still geting same error....

    Java Code:
    import java.sql.Connection;  
    import java.sql.DriverManager;  
    import java.sql.ResultSet;  
    import java.sql.Statement;  
    public class ConnectMSSQL {  
        public static void main(String[] args) {  
            try {  
                Connection connection = DriverManager  
                                "proba", "123456");  
                System.out.println("DATABASE NAME IS:"  
                        + connection.getMetaData().getDatabaseProductName());  
                Statement statement = connection.createStatement();  
                ResultSet resultSet = statement  
                        .executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");  
                while ( {  
                    System.out.println("EMPLOYEE NAME:"  
                            + resultSet.getString("EMPNAME"));  
            } catch (Exception e) {  
    btw im not shure about username and password to connect to db......
    on security.... right mouse.... new login.... select radiobuttun SQL Server authentication, login name: "proba" password and confirm: "123456"
    do i here create username and password to connect to db??
    Last edited by selomojemalo; 08-03-2013 at 01:42 AM.

Similar Threads

  1. Connect Syslog server with Java
    By may28 in forum New To Java
    Replies: 0
    Last Post: 01-07-2011, 02:40 PM
  2. Unable to connect to ftp server java
    By sagngh8 in forum Networking
    Replies: 1
    Last Post: 12-22-2010, 05:55 AM
  3. Java to connect remote server
    By idealguy in forum New To Java
    Replies: 1
    Last Post: 12-14-2010, 12:40 PM
  4. Replies: 3
    Last Post: 03-28-2010, 07:55 AM
  5. connect to web server from mobile using java app.
    By jankrishnan in forum Advanced Java
    Replies: 1
    Last Post: 07-15-2008, 05:12 PM

Posting Permissions

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