473,435 Members | 1,490 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,435 software developers and data experts.

Runtime errors while getting property file in netbeans 6.5

bansari
20
This Is My CODE::
Expand|Select|Wrap|Line Numbers
  1. package assign21;
  2.  
  3. import java.io.FileInputStream;
  4. import java.util.*;
  5. import java.sql.*;
  6.  
  7.  
  8. public class WithPropertyFile
  9. {
  10.  
  11.     String driver=null;
  12.  
  13.     String url = null;
  14.  
  15.     String username = null;
  16.     String psword = null;
  17.  
  18.     String propFile="D:/Bansari_Trainee/bansari_assign/Assign 2/Assign 2.1/assign2.1/src/assign21/DataProperty.properties";
  19.     public static String databaseInfo = "";
  20.     public static Connection connect;
  21.     public static ResultSet result;
  22.     public static ResultSet result1;
  23.     ResultSetMetaData rsMetadata;
  24.     int iColumnCount;
  25.     public static Statement statementObject;
  26.     PropertyResourceBundle pBundle = null;
  27.  
  28.  
  29.     public WithPropertyFile() {
  30.  
  31.     try{
  32.  
  33.         System.out.println("\n--Properties File Path  is ----"+propFile);
  34.         pBundle = new PropertyResourceBundle(new FileInputStream(propFile));
  35.                     databaseInfo =  (pBundle.handleGetObject("POSTGRE")).toString();
  36.                     System.out.println("\nOpening database-------------\n");
  37.                     System.out.print(propFile);
  38.                     if (!databaseInfo.equals(null)){
  39.  
  40.     StringTokenizer st = new StringTokenizer(databaseInfo);
  41.  
  42.         driver = st.nextToken();
  43.         System.out.println("\nDriver =>" + driver);
  44.         url = st.nextToken();
  45.         username = st.nextToken();
  46.         psword = st.nextToken();
  47.  
  48.         System.out.println("\nurl = " + url + "\npassword = " + psword);
  49.                     }
  50.  
  51.  
  52.     }
  53.  catch(Exception e){e.printStackTrace();}
  54.  
  55.     }
  56.  
  57. public WithPropertyFile(String propfile){
  58.         propFile=propfile;
  59.         new WithPropertyFile();
  60.     }
  61.  
  62. public void open()
  63.         {
  64.             try{
  65.  
  66.  
  67.                             Class.forName(driver);
  68.                             // create connection
  69.                                connect = DriverManager.getConnection(url,username,psword);
  70.                                 statementObject = connect.createStatement();
  71.              //                  result = statementObject.executeQuery("SELECT * FROM usermaster");
  72.                             System.out.println("Your Connection is Established...");
  73.  
  74.  
  75.  
  76.         }
  77.         catch(Exception e)
  78.             {
  79.                 e.printStackTrace();
  80.             }
  81.         }
  82.  
  83.  
  84.     public void close()
  85.         {
  86.         try{
  87.             connect.close();
  88.         }
  89.         catch(Exception e)
  90.             {
  91.                 e.printStackTrace();
  92.             }
  93.     }
  94.  
  95. }
  96.  
  97.  class DBConnection {
  98.  
  99.     public static void main(String args[]){
  100.  
  101.  
  102.        System.out.println("-------- PostgreSQL JDBC Connection Testing ------------");
  103.  //     System.out.println(System.getProperty("user.dir"));
  104.  
  105.             try
  106.                   {
  107.                 System.out.println("hi");
  108.                     PropertyResourceBundle pBundle = null;
  109.                     //System.out.println("h32i");
  110.                       pBundle = new PropertyResourceBundle(new FileInputStream("D:/Bansari_Trainee/bansari_assign/Assign 2/Assign 2.1/assign2.1/src/assign21/DataProperty.properties"));
  111.                      //System.out.println("h32i");
  112.                      System.out.print(pBundle);
  113.                     String databaseInfo =  (pBundle.handleGetObject("POSTGRE")).toString();
  114.  
  115.                       if (!databaseInfo.equals(null))
  116.                       {
  117.                               WithPropertyFile dbConnect = new WithPropertyFile(pBundle.handleGetObject("POSTGRE").toString());
  118.                             dbConnect.open();
  119.  
  120.                               //dbConnect.close();
  121.                             System.out.println("Database Connection is Established From Connection Class...");
  122.                     }
  123.                       else
  124.                               System.out.println("\tNo such database found in properties file");
  125.  
  126.             }
  127.             catch(Exception e){
  128.             e.printStackTrace();}
  129.       }
  130.  
  131. }
  132.  
I m facing this runtime errorr::

java.lang.NullPointerException
java.util.PropertyResourceBundle@3e25a5
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
/src/assign21/DataProperty.properties
at assign21.WithPropertyFile.open(WithPropertyFile.ja va:67)

at assign21.DBConnection.main(WithPropertyFile.java:1 18)

This is my proprty file::

POSTGRE org.postgresql.Driver jdbc:postgresql:postgres postgres root4site



Please help as early as possible.
Jul 24 '10 #1
0 1286

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: iainw | last post by:
HI All, 1st post here, i wonder if you can help. We are about to upload CMS t a windows server and keep getting 2 errors below. We need to go LIVE an it's delaying us. An error occured when...
12
by: ABeck | last post by:
Hello List, I have ar more or less academical question. Can there arise runtime errors in a program, if the include of <string.h> has been forgotten? If all the arguments to the functions of...
0
by: gautcha | last post by:
I keep getting runtime error when i open outlook express i am using xp with the sp2 the error is at C:\ProgramFiles\OutlookExpress\msimn.exe Appilcation requested the runtime to terminate in an...
4
by: James | last post by:
I have the Application_Error event method in the Global.asax setup to send me an email regarding errors. But, I am getting reports from users that a specific page is producing a runtime error...
6
by: Brett | last post by:
Not sure what the problem is here... Trying to update from a datagrid to an access database using vb.net... Its not updating the database but Im not getting any errors... Here is my code... ...
1
by: ancy | last post by:
hi all I am calling a procedure within script.Even if the prcoedure is not executed successfully. In log file it is recorded as procedure successfully executed .How to capture errors in log file ...
0
by: prisesh26 | last post by:
hi, i am using struts in my project. all my errors are shows through action errors. now iam having a scenario where i need to display Errors from my action. so using addError. but i need to...
0
by: sg2611 | last post by:
I am getting a warning in my VB.Net application Warning Late bound resolution; runtime errors could occur. for the following code Private Function CreateReportHeader(ByRef ExcelApp As...
20
by: cowboyrocks2009 | last post by:
Hi, I need help to automate my code to take data from input file. Also I need to create it as a function so that I can pass it to some other program. I am new to Java so having a bit limitation to...
0
by: ndedhia1 | last post by:
I am having trouble loading a property file and keep getting this error when running my shell script that loads and runs my jar files, etc: no property file loaded, using defaults......
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.