Connection Failed While Using JDBC Driver And AD Authentication On MSSQL2000 Server On Windows2k And Windows2k3 Servers.
Apr 18, 2008
I am having MSSQLServer2000 on Win2k and Win2k3 server.
i have to connect these servers from a application using JDBC driver and AD Authentication.
I have programmed all the things needed for AD authentication in my application(changed url , using integratedSecurity=true), and it is working fine when my application connects to MSSQLServer2k5 on WinXP(which is added to same domain of my application).
But when i try to connect MSSQL2000 server on Win2000 server it failes and gives error as follows.
Apr 18, 2008 12:39:51 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI SNISecGenClientContextINFO: Failed to get the SPNcom.microsoft.sqlserver.jdbc.SQLServerException: Connection reset at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSChannel.read(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSReader.readResponse(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(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 ChangePassword.process(ChangePassword.java:33) at ChangePassword.main(ChangePassword.java:14)
I am using following code for connection --
String url = "jdbcqlserver://172.16.1.243\dbaudit;portNumber=1034;integratedSecurity=true";
Class dbDriverClass = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Driver driver = (Driver) dbDriverClass.newInstance();
Properties props = new Properties();
conn=driver.connect(url, props);
View 13 Replies
ADVERTISEMENT
Sep 5, 2006
Hi,
I have noticed that Connection.setTypeMap is not supported on the SQL Server 2005 JDBC driver.
The consequence is that it is impossible to use UDTs via JDBC. Is there any plan to implement this in the future ?
Thanks,
Ben
View 6 Replies
View Related
Aug 6, 2007
Hi,
I am facing problem in configuring and using connection pooling on tomcat 5.0. I am using JDBC Driver v.1.1 for SQL Server 2005.
Can anybody point me to appropriate samle code or guideline?
Thanks & Regards,
Bhavin P Panchal
View 5 Replies
View Related
Jun 30, 2005
Environment -
I am using Tomcat as my servlet engine and IIS as the Server. Additionally, I am using MS SQL 2000 as my DB. The DB resides on a seperate machine, and have created an ODBC JDBC connection on the local machine to access it. Additionally, the authentication for the DB is set to "Windows Authentication".
Problem -
Everything works fine if I simply run tomcat and access the databse. Also, things run fine when I run tomcat via IIS too. However, when I try accessing the database, I get the error
Login failed for user '<username>'
Now, the funny part is, this username is actually the username of the local machine on which the application has been placed. It is not the username that I am providing in
con=DriverManager.getConnection("jdbc : odbc : DBName","username","password"); /* had to add in extra spaces to stop this site from substituting :+D.etc to smiles*/
Can someone please help me figure it out?? Why is it working when I run the tomcat (Apache) and run the application from there, but ones I run it via IIS, it fails. Also, why is it taking the username from the local machine and not the one that I am providing out there?
View 4 Replies
View Related
Apr 14, 2008
I have read similar posts to this, but I am still having problems.
I am trying to use connection pooling to connect to a local SQL Server 2005 database. I am running my application using
MyEclipse Enterprise Workbench. I have verified that sqljdbc.jar resides in "WebRoot/WEB-INF/lib/"
"WebRoot/WEB-INF/web.xml":
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsichemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-ref>
<res-ref-name>jdbc/DefaultDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
"WebRoot/META-INFcontext.xml":
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/DefaultDS"
auth="Container"
type="javax.sql.DataSource"
username="tec"
password="tec"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDrive"
url="jdbcqlserver://localhost:1433/tec;databaseName=tec;user=tec;password=test;"
validationQuery="select 1"
maxActive="10"
maxIdle="2"/>
</Context>
Classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="com.genuitec.eclipse.j2eedt.core.J2EE14_CONTAINER"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/dom.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jaxen-full.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jaxp-api.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jdbc2_0-stdext.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/sqljdbc.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jstl.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/mail.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/sax.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/saxpath.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/standard.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xalan.jar"/>
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/xercesImpl.jar"/>
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>
Code to connect:
import java.io.Serializable;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public int testConnect(){
Connection conn = null;
InitialContext ctx = null;
java.sql.Statement stmt = null;
try {
ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/DefaultDS");/*This is generating the Cannot load JDBC driver class... error*/
conn = ds.getConnection();
stmt = conn.createStatement();
return CONSTANT.SUCCESS;
} catch (Exception e) {
return CONSTANT.FAILURE;
}finally {
try {
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
if (ctx != null)
ctx.close();
} catch (Exception ex) {
// do nothing
return CONSTANT.FAILURE;
}
}
}
Any ideas would be greatly appreciated.
View 17 Replies
View Related
Aug 8, 2006
Hi all,
We've just stumbled on a 1.0 version incompatibility with the JDBC specs.
Problem: A table with SMALLINT column. According to JDBC specs version 3.0
(p.B-179) and 4.0 (p.221)), the value should be converted to Integer type.
Unfortunatelly we get a Short object :(
Now, I remember, this case was also affecting old JSQLConnect driver from
DataDirect. Could that problem sneak to new MS driver too?
Please let me know any resolution to this problem if exists.
The issue has not been fixed in CTP 1.1 version. Any ideas if it can be fixed??
Cheers,
Piotr
View 1 Replies
View Related
Jan 18, 2001
please help it's urgent i badly need the jdbc driver for mssql for my project
thank u
View 1 Replies
View Related
Jan 18, 2005
Hi at all, i'm new here, your communitiy seems too much preparated.
My question is simple...
i must to connect via jdbc to a ms sql server 2000 database, but i'm in doubt to select which jdbc driver to use. your suggest over microsoft'drivers? i found on the internet the open source drivers jdts...what about them?
thank you and excuse for by bad english! :p
View 2 Replies
View Related
May 21, 2007
I am trying to connect to SQL Server 2005 Express with JDBC. I am getting the following exception:
Code SnippetString connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=IFC3;";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl,"ifc2","password");
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(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(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at connectURL.main(connectURL.java:43)
I am using the code example that came from Microsoft for making a JDBC connection. I looked at my configuration of SQL Server and change to use a static port 1433. I shut off Windows firewall to make sure it was not blocking communication.
When I try to telnet to port 1433 it says
Connecting To 1433...Could not open connection to the host, on port 23: Connect
failed
Any suggestions?
Thanks,
Tom
View 14 Replies
View Related
Jul 20, 2005
Hi,Could some please tell me whether Microsoft provides Type 2 and Type 4jdbc driver ? For Type 4 MS providescom.microsoft.jdbc.sqlserver.SQLServerDriver driver. What is thecofiguration required for type 2 driver and what driver class filesrequired ?Its very urgent to me please reply.Ajay
View 1 Replies
View Related
May 13, 2004
I have SQL server installed on a XP box. I need to access it from other machines using Java code. Where can I download a JDBC driver?
Thanks.
View 6 Replies
View Related
Jul 23, 2005
Hello JoeOver the past several years, I have found your responses to jdbcusage/driver related issues to be extremely helpful. I am sure thatyou're very busy so I will make my question as brief as possible - thereason I didn't post this to a newsgroup is that I don't want to hearany more hype or links to benchmarks (since the vast majority of thebenchmarks don't test concurent/mixed-transaction environments). (I amalso posting a modified version of this message to some newsgroups, butbased on past responses - don't have too much hope that these will leadto a resolution.) If the only way to answer this question would be tohave a phone conversation, my company would be more than happy to pay aconsulting-service fee for your time.My situation:My company has a enterprise level web-app that targets SQL Server. Wedon't use J2EE - so we stick to a simple to administer web containers(JRun,Tomcat). Recently, we have been getting worse and worseperformance from our jdbc driver (we use the free MS jdbc driver) -things like strange transaction resource handling, chopy overallperformance, etc.. I have spent significant time tweaking it (followingvarious advice - many times yours - on newgroups... I can go intodetails, but I don't want to take up your time). As the project'sarchitect, I need to do something about this problem - but varioushigh-level tunnings that I have done to the way we use connections withthis driver haven't significantly improved perfomance under normaleveryday load. (Our queries often span tables with millions of records,and are relatively dynamic. We use a seperate pool of autocommit-offconnections for writes, and autocommit-on connecions for reads)So, then, my question - in your expert opinion - what is the BESTdriver from SQL Server 2000 given the following needs:Things I need it to have are solid jdbc 1.0, solid transactionhandling, decent concurrent load handling, stable implementation ofresource handling (i.e. auto closing result sets when parent statementsclose, closing of result sets & statements when connections close) andsupport for multiple open statements/result sets per connection.Things I do not have a direct need for:Connection Pooling (I keep my own pool of open connections), DataSourcesupport, distributed transactions or 2-phase commit support, RowSetvariants, jdbc 3.0 autokey generation, J2EE compliance. We do make useof updatable result sets - but I don't care if it isn't supported sinceI can still use MS driver for those, as they are mainly done it batchjobs).Things that are nice:It would also be good to have a driver that can handle prep statementcaching on a driver level (vs connection level) although this isn't anecessity, and if it is available - it would need to have aconfigurable caching strategy (or have a way to be turned off :)I very much appreciate your help in advanceThanksGary BogachkovSystem ArchitectStericycle Direct Return
View 1 Replies
View Related
Jul 20, 2005
Dear All,I developed an web application which use MS SQL Server 2000. Iencounter the following SQLException "[Microsoft][SQLServer 2000Driver for JDBC]Error setting up static cursor cache". Did anyoneencounter this problem before? What does this exception mean and howto solve this problem?[Remarks: The web application work properly on development machine andthis machine but encounter this exception when move to anothermachine, so is this exception related to the machine?]Thank you for your attention.Yours faithfully,Benny
View 2 Replies
View Related
Jul 20, 2005
Dear all,Any MS SQL server driver for JDBC for window NT ?Thanks for reply.Victoria
View 2 Replies
View Related
Jan 3, 2007
Hi folks,
I'm trying to figure out if the SQL Server 2005 JDBC driver supports SSL at all. I've downloaded the driver documentation, looked at more web pages than I care to count, and even went as far as to take a stab at guessing at different driver property names in the hopes I might discover some undocumented feature. Each time I try, I come up dry.
The following exception shows up in my JBoss log:
2007-01-03 12:13:36,812 WARN [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: The SQL Server login requires an SSL connection.)
I know I have things working properly on the SQL Server side, as both osql and Query Analyzer work fine, and packet sniffing yields no plain text information. I've also tried swapping in the open source JTDS driver, and once again, sniffing shows that the data between the two machines in encrypted.
Does anyone know if I'm just missing something completely obvious, or can someone state with absolute certainty that the driver does not support SSL? Any ideas on how to find out if there are plans to support this feature and what the timeline might be?
Thanks in advance.
Trev.
View 3 Replies
View Related
Apr 1, 2007
Hi
Do we have to use SQL server 2005 JDBC driver to connect the sql server 2005? I got sql server 2000 driver for JDBC, it works fine to connect the database. But when I use sql server migration assistant for oracle, i got an error saying: [sql server 2000 driver for JDBC] Error establishing socket. Do I have to download SQL server 2005 driver for JDBC or I miss something else?
Thanks
Li
View 7 Replies
View Related
Jul 24, 2007
Can any version of the SQL Server 2000 JDBC driver connect to SQL Server 2005 or do I have to install the new JDBC version 1.1 to connect to my 2005 instance?
View 1 Replies
View Related
Jan 25, 2008
I have one query which executes properly with mssql 2000 jdbc driver but fails with the 2005 driver.
The query creates a table, using insert exec method tries to get the data in the created table. But, executing this statement fails producing exception com.microsoft.sqlserver.jdbc.SQLServerException: The statement did no
t return a result set.
the command is as:
insert into #temp exec ('dbcc inputbuffer (' + @spid + ')')
I tried executing only the dbcc command on the db with query analyzer, it returns the results correctly, even with the same driver if I execute the dbcc query it runs fine and returns the resultset. But, only when I use it with insert exec it fails.
Does anyone know why this error occurs and what can be work-around.
Thanks in advance.
View 4 Replies
View Related
Oct 7, 2006
Hola a todos. Saludos cordiales.
Tengo instalado Microsoft Windows 2003 Server Standard Edition en un servidor IBM xSeries 220, estoy tratando de instalar IBM Director 5.10 y no ha sido posible hacer que se conecte con la base de datos.
Esto ocurre cuando intento configurar el Servidor SQL en la fase final de la instalación de IBM Director.
Gracias por su ayuda, ¿puede alguien darme alguna sugerencia?
Erick Gómez, Venezuela
View 1 Replies
View Related
Oct 6, 2007
We have a problem with SQL Server 2005 v1.2 JDBC driver, where the application is failing with java.lang.OutOfMemoryError. We have a database of around 50 milion rows and our application has to query that database and operate on the large dataset. However, we are not facing this problem with databases having 1 million rows.
Database is running fine even after the java.lang.OutOfMemoryError in the application side. However, the application is not responding after this error.
We are facing this problem with SQL Server 2005 Standard Edition as well as Enterprise Edition.
Any help or suggestions will be highly appreciated.
View 1 Replies
View Related
Sep 28, 2006
Hi, will there be a Windows Mobile edition of this driver, so that is possible to connect to SQL Everywhere on a Pocket PC from Java ME apps?
Best regards.
Luca
View 12 Replies
View Related
Apr 8, 2006
I'm getting the following exception when attempting to connect to SQL Server 2005 using Microsoft's new JDBC driver:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
The help docs suggest checking connectivity using telnet. So attempting to connect via telnet to 127.0.0.1:1433 generates:
Could not open connection to the host, on port 23: Connect failed.
So I try to start telnet:
net start telnet
I get the following error message:
The service cannot be started either because it is disabled or because it has no enables devices associated with it.
Can anyone help?
Thanks
View 7 Replies
View Related
Mar 27, 2008
Is there a JDBC driver specific for 2005 Express ? Or should I be using the SQLServer 2005 JDBC driver -
If specific, please provide link!
Thanks,
MrCuban
View 1 Replies
View Related
Oct 18, 2007
Hi Friends ,
Recently I downloaded version 1.2 release of the Microsoft SQL Server 2005 JDBC Driver. Thanks a ton to Microsoft
for providing many new features such as Adaptive Buffering , SSL Encryption , Tightly Coupled XA Transactions etc.
I am mainly concerned about SSL part of it and would be grateful if you can solve my queries or forward it to app-
ropriate forum.
1 ) I tried connecting to SSL enabled SQL Server 2005 through a sample program provided by Microsoft along with this
package ( Version 1.2 ) and I succeeded whereas in previous versions I use to get an exception as "The SQL Server
login requires an SSL connection." My connection string is as follows "jdbcqlserver://Ip adress of dataserver
machine:1433;databaseName=master;user=sa;password=sapassword" .
Ideally we should only get an SSL connection when we request it else an error message should be thrown informing
the user that dataserver requires an SSL connection. This would help in choosing between type of communication
a user needs with dataserver.
The scenario now is like forcing a user to have SSL communication if dataserver forces it. A flag may be added
as ssl should be mandatory or auto .
2 ) Current driver 1.2 is not capable of communicating with MS SQL Server 2000 both in case of SSL and Non - SSL
cases , The error which we receive in both cases is :
Oct 18, 2007 4:57:17 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 TransactionID:0x0000000000000000 Prelogin response packet not marked as EOM
The TDS protocol stream is not valid.
To communicate with both MS SQL Server 2000 and 2005 a user will have to maintain both the drivers which may
increase complexity of the application , like loading both driver in a single process , etc etc . . .
If version 1.2 id built on top of Sql server 2000 JDBC drive then it should be able to handle following 4 cases :
i ) SQL Server 2005 - SSL ,
ii ) SQL Server 2005 - Non - SSL ,
iii ) SQL Server 2000 - SSL ,
iv ) SQL Server 2000 - Non - SSL .
If this single driver handles all above 4 cases , life of a developer and application developed by him/her would
become less complex.
3 ) Last but not the least , the SQL Server 2000 JDBC driver connects with both kind of SQL Server 2000 instances i.e.
SSL and Non - SSL without any certificate of flags specified. I was able to establish non - SSL connection with SQL
Server 2000 using two third party JDBC drivers which I think is not appropriate behaviour.
4 ) I have also noticed that when SQL Server 2005 is running in Non - SSL mode i.e. "ForecEncryption=No" and our Client
application requests SSL communication , we are not warned about server is not runnning in SSL mode , could you please
explain this ?
Kindly correct me I am wrong anywhere as I am just a beginner and don't have much knowledge on this subject .
Thanks a lot.
Sincerly ,
Sudhansu Tiwari
View 1 Replies
View Related
Feb 17, 2004
I have a problem in connecting to my hosting database using .net file.
I am able connect to database with my ASP page.
Any sugession is greately appretiated!
Here is my code:
".net" page:
<%@ page language='vb' debug='true' %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim MyConnection As SqlConnection
Dim da AS sqlDataAdaptor
Dim ds As DataSet
MyConnection = New SqlConnection("DSN=***;UID=***;PWD=***")
da = new sqlDataAdaptor("select * from city", MyConnection)
Try
MyConnection.open()
Response.write "Connection Success " & MyConnection.Database & "<br>"
catch sx AS sqlException
Response.write "Connection successful: <br>"
End Try
ds=new Dataset()
da.Fill(ds, "City")
With DataGrid1
.DataSource = ds.Tables("city").DefaultView
.DataBind()
End With
MyConnection.Close()
End Sub
</script>
<body>
<p>
<ASP:dataGrid id='DataGrid1' runat='server'/>
<p>
</body>
</html>
---------------------------------------------
"ASP" page:
Set DB = Server.CreateObject("ADODB.Connection")
DB.Open ConnectionString
SET RSCheckeMail = DB.Execute ("select * from city")
While not RSCheckeMail.eof
Response.write "City: " & RSCheckeMail("Name") & "<br>"
RSCheckeMail.Movenext
Wend
Thanks for your help in advance.
View 8 Replies
View Related
Jul 10, 2007
Hi,
I have a J2EE based web application. There is a requirement where user triggers a process to query a database, and the application needs to save the results to an SDF file (Microsoft SQL Server CE 2.0 / Microsoft SQL Server Compact Edition) database. I need JDBC driver for it, but could not find it anywhere. Please help. Also, if there is any alternate way to do this, please let me know.
Thanks,
Vaibhav
View 3 Replies
View Related
Apr 5, 2004
Hi,
Recently, I found a bug in Microsoft's official SQL Server2000 JDBC driver.
It seemed to lie in the Statement's setDate() method. Maybe they simply assumed
all date are represented in 12-hours format.
The test code is below:
public void testMisc() throws Exception {
Connection conn = TransactionManager.getConnection();
String sql = "select count(salescheck0_.ID) as x0_0_ " +
"from T_CHK_OUT_BILL_TEST salescheck0_ " +
"where (salescheck0_.EX_TIME>?)" +
"and(salescheck0_.EX_TIME<?)";
PreparedStatement stmt = conn.prepareCall(sql);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date timefrom = sdf.parse("2004-04-02 00:00:00.000");
Date timeto = sdf.parse("2004-04-02 23:00:00.000");
stmt.setDate(1, new java.sql.Date(timefrom.getTime()));
stmt.setDate(2, new java.sql.Date(timeto.getTime()));
// stmt.setString(1, "2004-04-02 00:00:00.000" );
// stmt.setString(2, "2004-04-02 23:59:59.000" );
ResultSet rs = stmt.executeQuery();
if(rs.next()) {
int count = rs.getInt(1);
System.out.println("count = " + count);
}
}
The test data is following:
ID, SO_ID,WH_ID,CLIENT_ID,CODE,OPERATOR,CHK_OUT_TIME, STATUS,CREATE_TIME,DELIVER_TYPE
86179,67521,1,661,SLCCK200404020016,xuwei,2004-4-2 12:15,20,2004-4-2 9:40,10
86229,67566,1,118,SLCCK200404020066,xuwei,2004-4-2 12:23,20,2004-4-2 9:41,10
86231,67568,1,130,SLCCK200404020068,xuwei,2004-4-2 12:23,20,2004-4-2 9:41,10
86232,67569,1,134,SLCCK200404020069,xuyili,2004-4-2 11:08,20,2004-4-2 9:41,10
86233,67571,1,151,SLCCK200404020070,xuwei,2004-4-2 12:23,20,2004-4-2 9:41,10
86234,67572,1,55,SLCCK200404020071,xuwei,2004-4-2 12:23,20,2004-4-2 9:41,10
86235,67573,1,71,SLCCK200404020072,xuwei,2004-4-2 12:23,20,2004-4-2 9:41,10
86252,67590,1,298,SLCCK200404020089,xuwei,2004-4-2 12:33,20,2004-4-2 9:41,10
86268,67576,1,25,SLCCK200404020105,xuwei,2004-4-2 12:23,20,2004-4-2 10:18,10
86269,67588,1,271,SLCCK200404020106,xuwei,2004-4-2 12:33,20,2004-4-2 10:20,10
86270,67506,1,42,SLCCK200404020107,xuwei,2004-4-2 12:15,20,2004-4-2 10:21,10
86271,67531,1,751,SLCCK200404020108,xuyili,2004-4-2 11:28,20,2004-4-2 10:22,10
86272,67570,1,149,SLCCK200404020109,xuwei,2004-4-2 12:23,20,2004-4-2 10:29,10
86273,67600,1,6,SLCCK200404020110,xuwei,2004-4-2 12:15,20,2004-4-2 10:40,10
86373,67665,3,686,SLCCK200404020210,root,2004-4-2 17:18,20,2004-4-2 16:32,10
86374,67657,3,883,SLCCK200404020211,root,2004-4-2 17:18,20,2004-4-2 16:32,10
86375,67666,3,686,SLCCK200404020212,root,2004-4-2 17:18,20,2004-4-2 16:32,10
86376,54799,1,395,SLCCK200404020213,zhouliyi,2004-4-2 19:52,20,2004-4-2 19:51,10
86377,55383,1,341,SLCCK200404020214,zhoulingyi,200 4-4-2 19:52,20,2004-4-2 19:51,10
Given the code and data, the expected output ought to be "count = 19"
But it's "count = 19" instead.
However, if you set date by using alternative method like the commented statements,
you can get the correct result.
Does anybody know if there exists any patch?
Could we expect Mircosoft to fix this bug? If so, where could I submit this bug report?
Regards,
Justin
View 3 Replies
View Related
Apr 26, 2007
hi,Does MS2005 JDBC Driver 1.1 support integrated security on Solaris and if sohow?Thanks,MarcM
View 1 Replies
View Related
Jan 11, 2008
I'm encountering a problem that seems to be due to the StreamError class not being serializable. This was raised on the JDBC Driver Team blog by Jonas on 10/24/2007. Jimmy Wu notes on 10/29/2007 that it is under investigation. Any progress?
http://blogs.msdn.com/jdbcteam/archive/2007/10/12/microsoft-sql-server-2005-jdbc-driver-v1-2-official-release.aspx#comments
Thanks,
Mike
View 2 Replies
View Related
Feb 22, 2006
We are in the process of configuring a j2ee application with SQL Server 2005. We have downloaded the new version of SQL Server 2005 Java Database Connectivity (JDBC) Driver 1.0.
We are having some issues in getting it to work using the XA datasource. Description of the error is as follows:
javax.transaction.xa.XAException: java.sql.SQLException: Failed to create the XA control connection. Error: Could not find stored procedure 'master..xp_sqljdbc_xa_init'..
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(Unknown Source)
Has anyone else has encountered this and possibly found a solution.
Regards,
Bindu
View 33 Replies
View Related
Dec 7, 2006
Hi All,
My java application executes one stored procedure that returns two resultsets and then deal with data. The code actually is very simple
Statement stmt = con.createStatement(); con is database connection
ResultSet rs = stmt.getResultSet();
//Do something
rs.close();
rs = stmt.getResultSet();
//Do something
Then I got the error: The result set is closed.
The code worked well with jdbc sql server 2000 driver.
Thanks for your help.
Eric
View 1 Replies
View Related
May 21, 2008
I'm having a heck of a time trying to access a SQL server database using Saxon's SQL extensions with the Microsoft SQL server JDBC driver. The Saxon XSL processor has implemented some SQL extensions that allow you to access a SQL database through a JDBC driver. I have Visual Studio 2005 professional with SQL server express installed on my workstation. The SQL server express installation is installed at the default 1433 port on my workstation, it has been setup to accept connections over TCP and has been configured to accept Windows authentication and SQL authentication. In addition, I have downloaded and installed Microsoft's JDBC driver for SQL server.
After installing the JDBC driver I added the JDBC sqljdbc.jar to my Java CLASSPATH. Then I built a simple Saxon XSL that made use of the SQL extensions:
Code Snippet
<xsl:transform version="2.0"
exclude-result-prefixes="java saxon xsd xsi xsl xfn xdt xqe"
extension-element-prefixes="saxon sql"
xmlns:java="http://saxon.sf.net/java-type"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="java://net.sf.saxon.sql.SQLElementFactory"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="text" media-type="text/plain" encoding="utf-8" />
<xsl:preserve-space elements="*" />
<xsl:param name="jdbc.driver" as="xsd:string" select="string('com.microsoft.sqlserver.jdbc.SQLServerDriver')" />
<xsl:param name="jdbc.database" as="xsd:string" select="string('jdbc:sqlserver://localhost:1433;databaseName=prototype')" />
<xsl:param name="jdbc.user" as="xsd:string" select="string('saxon')" />
<xsl:param name="jdbc.pass" as="xsd:string" select="string('*****')" />
<xsl:template match="/">
<xsl:choose>
<xsl:when test="element-available('sql:connect')">
<xsl:variable name="sql.conn" as="java:java.sql.Connection">
<sql:connect driver="{$jdbc.driver}" database="{$jdbc.database}" user="{$jdbc.user}" password="{$jdbc.pass}">
<xsl:fallback>
<xsl:message terminate="yes">SQL extenstions are not installed</xsl:message>
</xsl:fallback>
</sql:connect>
</xsl:variable>
<xsl:variable name="sql.employees" as="element()*">
<sql:query connection="$sql.conn" table="dbo.Employees" column="*" />
</xsl:variable>
<xsl:sequence select="$sql.employees" />
<sql:close connection="$sql.conn" />
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">sql:connect element is not available</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:transform>
When I run the Java version of Saxon it issues a JDBC connection failure:
SXSQ0003: JDBC Connection Failure: The TCP/IP connection to the host has failed.
java.net.ConnectException: Connection refused: connect
Transformation failed: Run-time errors were reported
After some discussion on the Saxon listserv, I hacked a sample in the Microsoft JDBC documentation to see whether a standard Java program could use the JDBC driver and access the database:
Code Snippet
import java.sql.*;
public class connectURL {
public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl = "" +
"jdbc:sqlserver://localhost:1443" +
";databaseName=prototype";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl, args[0], args[1]);
// Create and execute an SQL statement that returns some data.
String SQL = "SELECT * FROM dbo.Employees";
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) + " " + rs.getString(3) + " " + rs.getString(4));
}
}
// Handle any errors that may have occurred.
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) {}
}
}
}
This Java application accesses SQL server express and prints out the list of employees from the dbo.Employees table in the database:
Code Snippet
-- Create the table definition.
CREATE TABLE dbo.Employees
(
empid INT NOT NULL PRIMARY KEY,
mgrid INT NULL REFERENCES dbo.Employees,
empname VARCHAR(25) NOT NULL,
salary MONEY NOT NULL,
CHECK (empid <> mgrid)
);
GO
-- Insert test data.
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 1, NULL, N'David' , $10000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 2, 1, N'Eitan', $7000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 3, 1, N'Ina', $7500.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 4, 2, N'Seraph', $5000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 5, 2, N'Jiru', $5500.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 6, 2, N'Steve', $4500.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 7, 3, N'Aaron', $5000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 8, 5, N'Lilach', $3500.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 9, 7, N'Rita', $3000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 10, 5, N'Sean', $3000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 11, 7, N'Gabriel', $3000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 12, 9, N'Emilia', $2000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 13, 9, N'Michael', $2000.00 );
GO
INSERT INTO dbo.Employees( empid, mgrid, empname, salary )
VALUES( 14, 9, N'Didi', $1500.00 );
GO
-- Create unique index.
CREATE UNIQUE INDEX idxManagerEmployee ON dbo.Employees( mgrid, empid );
GO
Internally, Saxon uses almost the exact same code, e.g., three argument DriverManager.getConnection, but the call fails. Michael Kay, has indicated that this issue isn't related to Saxon since the error message coming from Saxon indicates that Saxon is finding the JDBC driver and issuing the connection request, but the JDBC driver is failing.
Has anyone tried to use Saxon's SQL extensions with Microsoft's JDBC driver? If you have could you indicate how you have things setup to make it work? If anyone from Microsoft's JDBC driver team is listening, would you be will to help recreate this issue or help trying to diagnose the issue?
Thanks, Andy.
View 3 Replies
View Related