Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Lambodar Eng.   on Feb 22 In Java Category.

  
Question Answered By: Oscar Evans   on Feb 22

I tried your problem  but the jdbc  works as well as on the stored  Procedures which returns  a result set in T-SQL (SQL Server sql  language)

create  a stored procedure  like this in my database


CREATE PROCEDURE spSelectTexts AS

SELECT * FROM ST_TXT
WHERE ID_OR = 2
GO

and It then

a code like this


package com.ararat.dataaccess;

import java.sql.*;
/**
* <p>Title: ARARAT Retailing System</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author Soheil Dowlatshahi
* @version 1.0
*/

public class  TestDatabase {

 public  static void main(String[] args) {

 try  {
Class driverClass = Class.forName("com.inet.tds.TdsDriver");
Connection conn = DriverManager.getConnection("jdbc:inetdae:127.0.0.1:1433?database=arts","sa","");
CallableStatement stmt = conn.prepareCall("{call spSelectTexts ()}");


ResultSet rs = stmt.executeQuery();

for (int j =0; rs.next() && j < 10;j ++ ) {
for(int i= 1; i < 4; i++) {
System.out.print(rs.getObject(i) + " ");
}
System.out.println("");
}

rs.close();
stmt.close();
conn.close();


} catch(Exception ex) {

ex.printStackTrace();
}

}
}


I think that you have problem is related to two possible cases:

1. you use a invalid Driver ( I uses Inet Driver TDS http://www.inetsoftware.de/English/produkte/JDBC_Overview/ms.htm)
2. you have some bugs in your proxy  class or you EResultset

Note: As an answer to Hamid Reza Sahlolbey I should say that the in T-SQL we can return  a result set as the return value of a store procedure if we don't specified an explicit Return in our code. It's different from Oracle PL/SQL which requires that all result set return values must be Cursors or something like this

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem with JDBC, SQL Server 7.0 and Stored Procedures Or get search suggestion and latest updates.


Tagged: