• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Database URL

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to access MS SQL Server Database using Java application and JDBC.
I have created System DSN "JDBCTest" using 32 bit ODBC Administrator.
I would like know if the following syntax for database URL is correct :
String dbURL = "jdbc:0dbc:JDBCTest"
Thanks
 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Getting error when I run the following code java.sql.SQLException: [Microsoft][ODBC Driver Manager]Invalid Cursor State
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:4089)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
import java.sql.*;
public class Lookup {
public static void main(String args[]) {
String dbURL = "jdbc dbc:JDBCTest";
String user = "dbo";
String password = "dbo";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection(dbURL,user,password);
Statement s = c.createStatement();
ResultSet r = s.executeQuery("select user_id from tuser where user_last_nm = 'kalyankar'");
System.out.println(r.getString("user_id"));
}
catch (Exception e) {
e.printStackTrace();
}
}
}
What could be the problem ?
Thanks
[This message has been edited by Dilipkumar Kalyankar (edited October 19, 2000).]
[This message has been edited by Dilipkumar Kalyankar (edited October 19, 2000).]
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding exception logic whn registering your driver...
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
Look withn this form for complete java/odbc code examples.
I have posted a few... search for 'monty6'
Hope this Helps.

------------------
We learn more from our mistake's than from our success's.
 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Monty,
After replacing
System.out.println(r.getString("user_id"));
with
while (r.next()) {
System.out.println(r.getString("user_id"));
}
it worked.
Thanks
[This message has been edited by Dilipkumar Kalyankar (edited October 20, 2000).]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic