How To Configure Distributed Transaction / XA Support Using Microsoft SQL Server 2005 JDBC Driver.
May 30, 2007
I am trying to configure distributed transaction and XA support using Microsoft SQL Server 2005 JDBC Driver. I have coppied SQLJDBC_XA.dll from XA directory and placed in my sql server binn directory and trying to run the script xa_install.sql from binn directory with command as below :
C:Program FilesMicrosoft SQL Server80ToolsBinn>
osql -U sa -n -P admin -S localhost -i C:JavaLibrariesMS SQL Driversqljdbc_1.2enuxa xa_install.sql
But I am getting error saying :
[DBNETLIB]SQL Server does not exist or access denied.
[DBNETLIB]ConnectionOpen (Connect()).
when I replaced local host with the machine name it gives error :
[Shared Memory]SQL Server does not exist or access denied.
[Shared Memory]ConnectionOpen (Connect()).
where in I am able to test connection from Websphere using the same connection.
Please help some one ....... I am in URGENT need.... I need to enable XA suport for my application to run........
Thanks ----
View 2 Replies
ADVERTISEMENT
Feb 14, 2007
I have some code that should execute multiple statements and then commit. I am using the Microsoft SQL Server 2005 JDBC Driver 1.1.
The statements only commit ifI close the connection to the SQL Server 2005 instance. I've looked at the example given at http://msdn2.microsoft.com/en-us/library/ms378931.aspx and it doesn't require closing the connection in order to commit.
Example:
public void doCall(Connection con) {
try {
/*Turn off AutoCommit.*/
con.setAutoCommit(false);
/**Call Two Stored Procedures.*/
Statement stmt = con.preapareCall(/*Java Code*/);
stmt.setObject(/*Java Code*/);
stmt.execute();
Statement stmts = con.preapareCall(/*Java Code*/);
stmt2.setObject(/*Java Code*/);
stmt2.execute();
/**Commit the transaction.*/
con.commit();
}
catch (SQLException ex) { //If some error occurs handle it.
ex.printStackTrace();
try {
con.rollback();
}
catch (SQLException se) {
se.printStackTrace();
}
}
}
My transaction never commits, and when I try to query the associated database tables in Microsoft SQL Server Management Studio 2005 my query hangs.
View 7 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
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
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
Feb 14, 2008
Hi, We are looking for a way to create the jdbc connection with Microsoft jdbc driver on a TomCat server ? Meaning the exact information to enter within the server.xml file or within the Tomcat web server administration tool - data source GUI.
thanks
View 1 Replies
View Related
Dec 14, 2006
I am using Microsoft SQL Server 2005 JDBC Driver to connect to SQL Server 2000 database, I am using the following connection URL
boolean iSecurity = true;
String connectionUrl = "jdbc:sqlserver://machine_name:1433;" + "databaseName=dbname;integratedSecurity=" + iSecurity;
I am getting the following error.
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication.
How do I resolve it? I have the following set
VMOPTIONS = -Xrs -Djava.compiler=NONE -Djava.library.path=C:Microsoft SQL Server 2005 JDBC Driversqljdbc_1.1enuauthx86sqljdbc_auth.dll
Any help will be highly appreciated.
Regards
Arup
View 1 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
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
Feb 29, 2008
We have a test db, a staging db and a live db. I have a stored procedure that runs fine on test and staging, but throws the following error on live.
The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.
The stored procedure uses linked servers and a transaction.
We're using the following transaction code in the stored procedure
BEGIN
BEGIN TRANSACTION
BEGIN TRY
---
procedure stuff here
---
COMMIT TRANSACTION
END TRY
BEGIN CATCH
DECLARE @ErrorSeverity INT, @ErrorNumber INT, @ErrorMessage NVARCHAR(4000), @ErrorState INT
SET @ErrorSeverity = ERROR_SEVERITY()
SET @ErrorNumber = ERROR_NUMBER()
SET @ErrorMessage = ERROR_MESSAGE()
SET @ErrorState = ERROR_STATE()
IF @ErrorState = 0
SET @ErrorState = 1
RAISERROR ('ERROR OCCURED:%d', @ErrorSeverity, @ErrorState, @ErrorNumber)
IF XACT_STATE() < 0
ROLLBACK TRANSACTION
END CATCH
END
I found the following link which seems to be the problem we're experiencinghttp://support.microsoft.com/kb/937517
The link includes a workaround which is the following:
"To prevent the SQLNCLI provider from sending an attention signal to the server, use the SQLNCLI provider to consume fully any rowsets that the OLE DB consumer creates. "
How do I use the SQLNCLI provider to fully consume any rowsets?
View 11 Replies
View Related
Feb 23, 2004
The microsoft JDBC driver doesn't accept CLOB & BLOB field.
Does anyone know about this problem ?
Is it possible to found another driver that works correctly and that is free ?
Thank's
View 2 Replies
View Related
Jan 25, 2008
Hi,
Anyone know what I'm doing wrong? My JDBC is erroring. I'm using the Microsoft 1.2 driver, I have a SQL Server 2005 back end with the following clients connecting to it:
ASP.NET 2.0 web application
Visual Studio C# console applications (*2)
Java command line client.
Everything runs hunky-dory on my dev. environment (laptop, local, launched via Visual Studio) but now it's on the server, the Java client is erroring.
When I use the 1.2 sqljdbc.jar file, I get:
25-Jan-2008 12:20:29 com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 TransactionID:0x0000000000000000 Prelogin response packet not marked as a REPLY
My Error Trap:
--------------
SQL STATE : 08S01
ERROR CODE: 0
MESSAGE : The TDS protocol stream is not valid.
When I use the 1.1 file I get:
My Error Trap:
--------------
SQL STATE : 08S01
ERROR CODE: 0
MESSAGE : The TDS prelogin response is incomplete. The target server must be SQL Server 2000 or later.
I don't know what these errors mean. I've tried compiling as java 1.5 and 1.6 with the same results. It works fine on my laptop (Vista Home Premium) but won't when I try and connect to the server. I've searched the web on the error messages and can't find an answer yet.
Any help appreciated.
My drivers are the Windows versions. Also, everything else is working okay on the server: The consoles are up and running and the web browser connects and SELECTs, UPDATEs & INSERTs okay.
I ought to mention: My laptop is running SQL Server Development edition and the Server is running obviously something else.
My SQL Server version is 9.0.1399 and the OS is Windows Server 2003. SQL Authentication is mixed mode.
View 4 Replies
View Related
Mar 13, 2008
Distributed transactions were happily running between our SQL servers and then we installed Windows 2003 Server SP2 and all of a sudden we got this nice error message when attempting a remote data update via linked servers. I couldn't even run "BEGIN DISTRIBUTED TRANSACTION" without getting the error message. The full error message is:
"Enlist operation failed: 0x8004d00e(XACT_E_NOTRANSACTION). SQL Server could not register with Microsoft Distributed Transaction Coordinator (MSDTC) as a resource manager for this transaction. The transaction may have been stopped by the client or the resource manager."
Apparently, SP2 disables network DTC access (how nice, I feel more secure knowing that my data can't be updated remotely anymore).
Solution:
From Control Panel | Add or Remove Programs | Add Remove Windows Components
Select "Application Server" and click the "Details" button
Check "Enable network DTC access" and click OK for however many prompts it takes to apply the changes.
****NOTE**** this change WILL SHUT DOWN SQL SERVER so plan accordingly (this would have been handy to know in advance since I ran it in the middle of the workday and everyone got disconnected).
Hope this helps!
View 2 Replies
View Related
Jun 25, 2007
I am unable to send null values through the Microsoft JDBC 1.1 driver to a stored procedure. Please look at the thread already started on the SQL Server Transact SQL Forum at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1772215&SiteID=1
View 1 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
Dec 19, 2006
HI,
We are migrating SQL2000 to SQL2005, we are using sql2005 jdbc driver 1.0.
I got this error "com.microsoft.sqlserver.jdbc.SQLServerException: Server failed to resume the transaction", when my application calls a stored procedure which is a transaction.
Does anyone know what could be the problem, how to fix it?
Thanks in advance.
View 5 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 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
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
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
Oct 5, 2006
Hi,
I'm using JDBC driver for Server 2005 (version 1.1.1501) to access Server 2000. I have no problems reading my data, but every update returns "Cursor is READ ONLY".
If I use driver for Server 2000 I have no problems. And I have no problems running the same program with 2005 driver against SQL Server Express.
Where should I start debugging?
Thank you,
View 1 Replies
View Related
Sep 11, 2007
Hello,
I'm trying to configure JBoss application server to use SQLServer 2005 as database with XA transactions.
I can start a new transaction, access SQLServer from within the transaction, but when committing, there is the following XAException from SQLServer:
16:04:20,926 INFO [STDOUT] javax.transaction.xa.XAException: java.sql.SQLException: COMMIT: Status:0 msg:*** SQLJDBC_XA DTC_ERROR Context: xa_commit, state=1, StatusCode:-4 (0xFFFFFFFC) ***16:04:20,926 INFO [STDOUT] at com.microsoft.sqlserver.jdbc.SQLServerXAResource.commit(Unknown Source)16:04:20,941 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.commit(XAManagedConnection.java:176)16:04:20,941 INFO [STDOUT] at com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord.topLevelOnePhaseCommit(XAResourceRecord.java:641)16:04:20,941 INFO [STDOUT] at com.arjuna.ats.arjuna.coordinator.BasicAction.onePhaseCommit(BasicAction.java:2619)16:04:20,941 INFO [STDOUT] at com.arjuna.ats.arjuna.coordinator.BasicAction.End(BasicAction.java:1779)
[...]
The system is running on Windows Server 2003 64bit with SQLServer 2005 64bit, and JBoss running on JDK 1.5.0 (32bit)
Can anyone tell me what this message indicates?
Regards,
Martin
View 3 Replies
View Related
Aug 22, 2007
Hi,
I am using SQL server 2005 stored procedures being called from my java application using the CallableStatement. As long as my stored procedure is a simple and direct Select statement things are moving nicely.
But my stored procedures are a little bit more complicated and this causes problems for me to parse the data in a ResultSet.
a sample stored procedure:
Create procedure sp_Get
@cat int,
@itemId bigint
as
declare @results table (tableId bigint, label varchar(200), typeId int)
if @cat = 1
begin
insert @results (tableId, label, typeId)
select
tableId = personId,
label = fname + lname,
typeId = 1
from Person where catId = @itemId
insert @results (tableId, label, typeId)
select
tableId = prospectId,
label = prospect,
typeId = 2
from Prospects where catId = @itemId
end
else if @cat = 2
begin
insert @results (tableId, label, typeId)
select
tableId = companyId,
label = Company,
typeId = 1
from Company where regionId = @itemId
end
/* result set*/
select
tableId,
label,
typeId
from @results
GO
my java code:
Connection conn = this.getConnection() //opens connection to db
CallableStatement cmd = conn.prepareCall(" { call sp_Get (?,?) }");
cmd.setInteger("cat", 1);
cmd.setLong("itemId", 2);
//this returns false?
boolean hasResults = cmd.execute();
//this also returns false?
boolean moreResults = cmd.getMoreResults();
The strange part of this is that when you execute this query in the SQL Server Managent Studio it returns 1 result set.
Why is my java code not able to see this result?
Thanks for any help,
- Rogier
View 1 Replies
View Related
Aug 15, 2006
I use the Microsoft SQL Server 2005 JDBC Driver (1.0.809.102 and 1.1.1320.0) to connect to a SQL Server 2005 database. I'm currently implementing a generic data access layer that executes an arbitrary SQL statement:
public void prepareQuery(String sql) throws SQLException, ClassNotFoundException {
PreparedStatement stm = getConnection().prepareStatement(sql);
ParameterMetaData pmd = stm.getParameterMetaData();
int numPar = pmd.getParameterCount();
System.out.println("Number of parameters: " + numPar);
// ... acquire and process 'numPar' parameters ...
}
Exemplarily, I created a table named 'TEST_TABLE' with three Integer columns ('C1', 'C2' and 'C3') and a Varchar column ('C4'). Calling
prepareQuery("INSERT INTO [TEST_TABLE] ( [C1], [C2], [C3], [C4] ) VALUES ( 1, 2, ?, ? )")
gives the following result:
Number of parameters: 4
This is definitely wrong because that statement has only two parameters, one of type Integer and one of type Varchar. How can I get the correct number and types of the parameters?
View 3 Replies
View Related
Mar 21, 2006
I'm having an issue with the JDBC driver when I execute a stored procedure that both has a return value and also returns a result set. If I attempt to retrieve the return value (registered as an output parameter) after I execute the stored procedure, then any subsequent attempts to retrieve the result set always return null. Is this by design? If I use the result set first and then later get the return value that works; however, in my situation I need to first check the return value before I work on the result set. Am I'm I doing something wrong?
Code:
CallableStatement cs = connection.prepareCall("{? = call spGetCustomer(?, ?) }");
cs.registerOutputParameter(1, Types.INTEGER);
cs.setString(2,"blahblahblah");
cs.setBoolean(3,false);
cs.execute();
int retVal = cs.getInt(1);
ResultSet rs = cs.getResultSet(); // Always returns null, even though the SP actually returns a result set.
View 36 Replies
View Related
Sep 5, 2007
Hi all,
I am trying to updated data on a different database on a different server. I am using linked servers for this. I can do select,updated , insert using the linked server in the management console but when i try to update the tables on remote server thru trigger i get this message MSDTC on server 'myserver' is unavailable. i checked the distributed transaction co-ordinator service in services.msc and its show that its running. Then i checked the logs in sql server 2005 and i see the following message
"The Microsoft Distributed Transaction Coordinator (MS DTC) service could not be contacted. If you would like distributed transaction functionality, please start this service."
i also see the the red stop icon on the distributed transaction co ordinator in under management in sql server 2005. i have enabled remote proc trans using sp_configure
Pls advise
View 1 Replies
View Related