This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 170016

Summary: Error connect to SQL Server 2008
Product: db Reporter: ekornschuh <ekornschuh>
Component: CodeAssignee: Jiri Rechtacek <jrechtacek>
Status: RESOLVED INCOMPLETE    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: DB Image
DB Image 2
DB Image 3
NB Image
NB Image 2
NB Image 3
NB Image 4
NB Image 5
NB Image 6
CN Image 1
CN Image 2
CN Image 3

Description ekornschuh 2009-08-07 03:31:20 UTC
Hello NB:

I couldn't connect to SQL server 2008 Express with JDBC from IDE, not from code, I use sqljdbc4.jar, the DB is local.

Thanks
Edgardo
Comment 1 Jiri Rechtacek 2009-08-11 17:11:56 UTC
Please, could you attach more information about your problem? NetBeans IDE build number, messages.log (found in View|IDE
Log) after trying connect to the server. Thanks
Comment 2 ekornschuh 2009-08-14 02:31:26 UTC
Created attachment 86219 [details]
DB Image
Comment 3 ekornschuh 2009-08-14 02:32:01 UTC
Created attachment 86220 [details]
DB Image 2
Comment 4 ekornschuh 2009-08-14 02:32:45 UTC
Created attachment 86221 [details]
DB Image 3
Comment 5 ekornschuh 2009-08-14 02:34:56 UTC
Created attachment 86222 [details]
NB Image
Comment 6 ekornschuh 2009-08-14 02:35:59 UTC
Created attachment 86223 [details]
NB Image 2
Comment 7 ekornschuh 2009-08-14 02:36:28 UTC
Created attachment 86224 [details]
NB Image 3
Comment 8 ekornschuh 2009-08-14 02:37:11 UTC
Created attachment 86225 [details]
NB Image 4
Comment 9 ekornschuh 2009-08-14 02:37:50 UTC
Created attachment 86226 [details]
NB Image 5
Comment 10 ekornschuh 2009-08-14 02:38:16 UTC
Created attachment 86227 [details]
NB Image 6
Comment 11 ekornschuh 2009-08-14 02:39:42 UTC
The Java Code is:

package conexion;

/**
 *
 * @author Administrador
 */
import java.sql.*;

public class conexion
{
    public static void main(String[] args)
    {

        // Create a variable for the connection string.
        String sUrl = "jdbc:sqlserver://localhost\\SQLEXPRESS;databaseName=prueba;integratedSecurity=true;";

        // Declare the JDBC objects.
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;

    try
    {
        System.out.println("--< Antes del Error >--");
        // Establish the connection.
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        con = DriverManager.getConnection(sUrl);

        // Create and execute an SQL statement that returns some data.
        String SQL = "SELECT TOP 10 * FROM usuarios";
        stmt = con.createStatement();
        rs = stmt.executeQuery(SQL);

        // Iterate through the data in the result set and display it.
        while (rs.next())
        {
            System.out.println(rs.getString(1) + " " + rs.getString(2));
        }
    }

    // Handle any errors that may have occurred.
    catch (Exception e)
    {
        System.out.println("Ocurrio un Error");
        e.printStackTrace();
    }

    finally
    {
        if (rs != null)
            try
            {
                rs.close();
            }
        catch(Exception e) {}
	if (stmt != null)
            try
            {
                stmt.close();
            }
        catch(Exception e) {}
	if (con != null) 
            try
            {
                con.close();
            }
        catch(Exception e) {}
    }
    }
}
Comment 12 Jiri Rechtacek 2009-08-17 15:26:58 UTC
Edgardo, thanks for information. But I still don't see where could be a problem. I tried to reproduce the issue with
MSSQL 2005 on localhost with sqljdbc4 driver (with JDK1.6!) and I can connect database. Check you HTTP network proxy in
Tools|Options and make sure localhost is among No Proxy Hosts (a button More in Manual Proxy Settings). Maybe it can
help. Regards
Comment 13 ekornschuh 2009-08-17 17:17:26 UTC
Created attachment 86334 [details]
CN Image 1
Comment 14 ekornschuh 2009-08-17 17:18:01 UTC
Created attachment 86335 [details]
CN Image 2
Comment 15 ekornschuh 2009-08-17 17:20:35 UTC
I have checked the HTTP proxy, but I have the same problem.
Thanks
Comment 16 ekornschuh 2009-08-22 21:04:03 UTC
Created attachment 86536 [details]
CN Image 3
Comment 17 ekornschuh 2009-08-22 21:05:15 UTC
I could connect via jdbc-odbc bridge , but I continue without connect via jdbc. One detail, Sql Server 2005 is similar 
to Sql Server 2008, but isn't the same. Could you send me a right configuration?