Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help! problem in getting ResultSet using JDBC-ODBC to connect to Pronto DB

843854Apr 16 2002 — edited Apr 17 2002
Hi everyone,

I hope you can help me solve this problem:

I'm using a sun JDBC-ODBC bridge to connect to my Pronto Database.
I've written a small java program to connect to the Pronto DB.
I can connect to Pronto already, got the correct number of rows I supposed to get.
(res.next() loop is repeated correctly as the number of rows I suppose to get from database)
but, the ResultSet data method getString returns empty string. (String length = 0)
I've checked using the ResultSetMetaData, and can get all information regarding my table like display size, columnlabel and column typename.

I dont think there is error in my code, becoz I can do the same thing for my Oracle database (ODBC driver), but maybe I'm wrong.

Could you please help to identify the possible cause of error and the solution for this?

Thanks.

Regards,

Har_A

==========
here is my code:

import java.sql.*;
import java.lang.*;
import java.io.*;

public class DB {

public static void main(String[] args){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(ClassNotFoundException e){
System.err.println("Error: " +e);
}

String url = "jdbc:odbc:Pronto DB";
String username = "username";
String password = "password";

try{
Connection conn = DriverManager.getConnection(url, username, password);
Statement stmt = conn.createStatement();

String queryStr = "SELECT accountcode, shortname FROM deb_master WHERE shortname LIKE 'AMD%'";
ResultSet res = stmt.executeQuery(queryStr);

System.out.println("The records are : ");

String accountcode;
String shortname;

while(res.next()){
accountcode = res.getString(1);
shortname = res.getString(2);

System.out.println("ID = " + accountcode + " Name = " + shortname);
}
res.close();
stmt.close();
conn.close();
} catch(SQLException e){
System.err.println("Error: " +e);

}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2002
Added on Apr 16 2002
4 comments
241 views