0

我的代码是:

        try{
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost;jithin-pc:1433;databaseName=news;IntegratedSecurity=true");
        String qr="SELECT * FROM base";
        Statement st=con.createStatement();
        ResultSet rs=st.executeQuery(qr);
        rs.next();
        System.out.println(rs.getString(1));
        out.println(rs.getString(1));

        }
        catch(Exception e)
        {
            System.out.println(e);
            out.println(e);
        }

我收到如下错误:

com.microsoft.sqlserver.jdbc.SQLServerException: The connection string contains a badly formed name or value.

我尝试更改 sql 设置防火墙等。请提供任何建议

4

1 回答 1

0

假设 jithin-pc 是 localhost,只要 localhost 或 jithin-pc 就足够了。

jdbc:sqlserver://localhost;databaseName=news;IntegratedSecurity=true
jdbc:sqlserver://jithin-pc;databaseName=news;IntegratedSecurity=true

还要检查这个

于 2013-01-02T07:59:54.073 回答