Hi,
I am writing project in asp .net with sql server 2005. But I need support him by some applications like deamon in linux systems.(but it will be in windows) So i write it in java. I download jdbc driver and install it. I wrote simple project:
package MainW;
//import javax.mail.*;
//import javax.mail.internet.*;
//import com.sun.mail.smtp.*;
//import javax.swing.*;
//import java.awt.*;
//import java.awt.event.*;
//import java.io.*;
import java.sql.*;
//import java.text.DateFormat;
//import java.text.SimpleDateFormat;
//import java.util.*;
//import java.util.Date;
class Main
{
public static void main(String[] args)
{
String connectionUrl = "jdbc:" + "sqlserver://localhost;databaseName=ASPNETDB.MDF;IntegratedSecurity=True";
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
String SQL = "SELECT * FROM aspnet_Users";
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(4) + " " + rs.getString(6));
}
}
catch (Exception e)
{
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) {}
}
}
}
But i have error:
2007-08-20 15:20:59 com.microsoft.sqlserver.jdbc.AuthenticationJNI SNISecGenClientContext
WARNING: Initialize context failed
2007-08-20 15:20:59 com.microsoft.sqlserver.jdbc.SQLServerConnection SSPIData
WARNING: ConnectionID:1 TransactionID:0x0000000000000000 Authentication failed code-2146893052
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.SSPIData(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at MainW.Main.main(Main.java:29)
I am googling about this error second day but i cannot find solve.
Please help.
The failure code -2146893052 is 0x80090304. Some results on the Internet mentions firewall blocking the SQL Server TCP port, but since you are connecting to the local machine it should not be a problem. I also heard of out of memory scenarios causing this error to be raised.
I think it would be helpful if you can mention the environment setup you are running the app under. Also, which SQL Server 2005 edition on you using?
Some things you may consider trying:
On the same machine, try running the "sqlcmd" tool that comes with SQL Server 2005 to see if you get the same error
sqlcmd -Slocalhost -E
No comments:
Post a Comment