• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

resource bundle

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The bundle name should not include the ".properties" extension - it gets appended automatically.
reply
    Bookmark Topic Watch Topic
  • New Topic