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: Michael Evans   on Feb 22

At least I do get the
information printed out when I tried your class  separately. As you
say, there might be a bug in one of the other classes, but I am going
to try  it out also. THe only problem  I had was that I have a remote
server, and it could not find it. My final code was therefore:


import java.sql.*;

public class TestDB {

public static  void main(String[] args) {

try {

Connection conn = null;
Class driverClass = Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver");
String URL = "jdbc:odbc:driver={SQL Server};
server=SERVERNAME;uid=USERID;pwd=PASSWORD;database=DBNAME";
conn =DriverManager.getConnection(URL);

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();
}

}
}

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: