aspose file tools*
The moose likes Other Java Products and Servers and the fly likes resource bundle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "resource bundle" Watch "resource bundle" New topic
Author

resource bundle

vnsaravanakumar vnsaravanakumar
Greenhorn

Joined: Aug 29, 2005
Posts: 1
I am new to resource bundle. i have created a class file to connect to mysql by getting the connection string form property file, but the error displayed is
Exception in getConnection java.util.MissingResourceException: Can't find bundle for base name data.properties, locale en_US

The source of "connect_detail.java" is

package webbean;
import com.mysql.jdbc.Driver;
import java.util.ArrayList;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.servlet.*;
import java.sql.*;

public class connect_detail
{

public connect_detail()
{
}

private java.sql.Connection conn = null;

private static final String PROP_FILE = "data.properties";

public java.sql.Connection getConnection()
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResourceBundle bundle = ResourceBundle.getBundle(PROP_FILE);
System.out.println("db url:"+bundle.getString("urldata"));

conn=DriverManager.getConnection(bundle.getString("urldata"));
if(conn == null)
System.out.println("Inside the getConnection() failure - conn is null");
else
System.out.println("Inside the getConnection() sucesss");
}
catch(Exception e)
{
System.out.println("Exception in getConnection() " + e);
}
return conn;
}
}


And the "data.properties" file is

#Database Connection

urldata = jdbc:mysql:/localhost/ems?user=root&password=root

Please help me to solve this problem
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39534
    
  27
The bundle name should not include the ".properties" extension - it gets appended automatically.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resource bundle
 
Similar Threads
Jdbc Connection pooling using apche tomcat6.0.14 and axis2--please help me
mysql connectivity with jboss
ClassNotFoundException while trying to connect to Oracle
Multiple Database Connection. Best practice?
Problem in ireport