Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 06:30 PM
Senior Member
 
Join Date: Jun 2007
Posts: 119
Peter is on a distinguished road
Property File
I have this code but it have the problem about load file. Please help me load the file I need("ODBC-JDBC Driver.properties")
Code:
import java.io.*; import java.sql.*; import java.util.*; public class TestCode { static final String PROPERTY_FILE="ODBC-JDBC Driver.properties"; String driverName, url, user, password; public void Test() { try{ Properties prop=new Properties(); prop.load(new FileInputStream(PROPERTY_FILE)); driverName=prop.getProperty("driver"); // Retrieve driver information. url=prop.getProperty("url"); // Retrieve JDBC URL. user=prop.getProperty("user"); // Retrieve user name. password=prop.getProperty("password"); // Retrieve password. Class.forName("driverName"); Connection con=DriverManager.getConnection(url,user,password); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("SELECT * FROM Registered_Users_Information"); while(rs.next()){ System.out.println(rs.getString("UserName")); System.out.println(rs.getString("Password")); } }catch(Exception ex){ ex.printStackTrace(); } } public static void main(String args[]){ TestCode t=new TestCode(); t.Test(); } }

Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-04-2007, 05:41 PM
Senior Member
 
Join Date: Jun 2007
Posts: 130
Jack is on a distinguished road
Put the file in the directory indicated by user.dir
( System.getProperty("user.dir"); )
or specify the entire path.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-04-2007, 05:48 PM
Senior Member
 
Join Date: Jun 2007
Posts: 164
Heather is on a distinguished road
Class.forName("driverName");
should be
Class.forName(driverName);
without the quotes.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to store property file into key value pair Java Tip java.util 0 04-05-2008 12:16 PM
Initializing property object from a file Java Tip Java Tips 0 12-29-2007 06:55 PM
property for radio buttons swapnanair JavaServer Pages (JSP) and JSTL 2 12-03-2007 10:39 AM
where is the system.property osval Advanced Java 2 08-06-2007 05:54 AM
log4j property file in my application Peter Advanced Java 3 06-14-2007 05:12 AM


All times are GMT +3. The time now is 11:42 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org