aspose file tools*
The moose likes JDBC and the fly likes JDBC using ResourceBundle Class Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC using ResourceBundle Class Problem " Watch "JDBC using ResourceBundle Class Problem " New topic

JDBC using ResourceBundle Class Problem

Nirlep Patel

Joined: Jul 29, 2007
Posts: 7

I am facing ClassNotFoundException problem

I am using NetBeans 5.5 IDE and using ResourceBunlde Class.

My code is:

package resobundledb;
import java.sql.*;
import java.util.*;

public class Main {

public static void main(String argv[]) {
Connection con = null;
//ResultSet rs;
ResourceBundle bundle = ResourceBundle.getBundle("dbresource");
System.out.println("Hello this is resourcebundle database connectivity 01");


String url = bundle.getString("URL");
System.out.println("url is: " + url);
Statement stmt;
ResultSet rs;

System.out.println("Driver is: " + bundle.getString("Driver"));
/* Load the Driver Class. */

System.out.println("Hello this is resourcebundle database connectivity 02");
//here is where the connection is made
con = DriverManager.getConnection(url, java.util.ResourceBundle.getBundle("resobundledb/dbresource").getString("root"), java.util.ResourceBundle.getBundle("resobundledb/dbresource").getString("password"));
//con = DriverManager.getConnection(url, "root", "password");
System.out.println("Hello this is resourcebundle database connectivity 03");
stmt = con.createStatement();

//rs = stmt.executeQuery(java.util.ResourceBundle.getBundle("resobundledb/dbresource").getString("select_*_from_tbluser"));
rs = stmt.executeQuery("select * from tbluser");

System.out.println("This is the result: ");

//int uid = rs.getInt("uid");
int uid = rs.getInt(1);

//String username = rs.getString("username");
String username = rs.getString(2);

//String name = rs.getString("name");
String name = rs.getString(4);

//String bdate = rs.getString("birthdate");
String bdate = rs.getString(5);

//double sscper = rs.getDouble("sscpercentage");
double sscper = rs.getDouble(6);

//double fees = rs.getDouble("fees");
double fees = rs.getDouble(7);

//String lastaccesstime = rs.getString("lastaccessedtime");
String lastaccesstime = rs.getString(8);

System.out.println("User id: " + uid);
System.out.println("User Name: " + username);
System.out.println("Name: " + name);
System.out.println("Birth Date: " + bdate);
System.out.println("SSC Percentage: " + sscper + " %");
System.out.println("Fees: " + "Rs. " + fees);
System.out.println("Last Accessed Time: " + lastaccesstime);
catch( SQLException e ) {
System.out.println("it is printing from SQLException");
catch(ClassNotFoundException e){
System.out.println("it is printing from ClassNotFoundException");
finally {
if( con != null ) {
try { con.close(); }
catch( Exception e ) { }
My properties file is:

select_*_from_tbluser=select * from tbluser
My database name is: tbluser

and it has following fields.

userid, username, password, name, birthdate, sscpercentage, fees, lastaccessedtime

I tried a lot since from last 2 days but could not get it.

still i am trying... if someone know help me


regards, nirlep,
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

You need to divide and conquer. Firstly, your app is too long. Solve the connection issue and then look at the rest.

1) Can you prove your properties file is being found
2) can you prove the Driver string value is read?
3) Can the application find the class on the classpath?

You haven't demonstrated that you can answer any of these, and at least one is failing.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

"Nirlep" please check your private messages.

I agree. Here's the link:
subject: JDBC using ResourceBundle Class Problem
Similar Threads
ClassNotFoundException with ResourceBundle
packages --- Not allowing me to access public class from the same package...
data mismatch error
accessing one class from other
Problem with the query in JDBC ,resultset empty