Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts how to access the messagresource.proprties filevalues in normal class file using struts
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


pradeep
how to access the messagresource.proprties filevalues in normal class file using struts
1 Answer(s)      4 years and 7 months ago
Posted in : Struts


i want to access the below username and password in class file.Plz help to me.


messageresource.properties files
username=system
password=system





My class file is

import java.io.PrintStream;
import java.sql.*;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.servlet.http.*;

import org.omg.CORBA.Request;
public class ConnectionDb {
public static Connection con=null;

//pradeep reddy



public static Connection getConnectionDb()throws Exception{


try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","system");




System.out.println("Connected database");
}catch(Exception e){
System.out.println("unnable to connect"+e);
}return con;
}
public static void main(String args[])throws Exception{
con=ConnectionDb.getConnectionDb();

System.out.println("connected");
}
}

Advertisement
View Answers

February 11, 2010 at 3:32 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.sql.*;
import java.util.*;
class UsePropertiesFile{
public static void main(String[] args)throws Exception {
Properties prop = new Properties();
prop.load(new FileInputStream("messageresource.properties"));
String user = prop.getProperty("username");
String pass = prop.getProperty("password");

Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test",user,pass);
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("Select * from data");
while(rs.next()){
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
}
}

Thanks


Related Tutorials/Questions & Answers:
how to access the messagresource.proprties filevalues in normal class file using struts - Struts
how to access the messagresource.proprties filevalues in normal class file using struts  i want to access the below username and password in class... password=system My class file is import java.io.PrintStream; import
How to access sub class member using super class object
How to access sub class member using super class object  class A{ } class B extends A{ int b=1; } class Test{ public static void main(String args[]) { what to do here to access sub class variable b using super class object
Advertisements
How and Where we Access struts Properties file - Struts
How and Where we Access struts Properties file   Hi Friends, am new to struts.I read that " you can store variables in xml file(properties file) and for future enhancements we just call properties file . Now i want to implement
Random Access File class
Random Access File class  Write a short note on Random Access File class.   Please visit the following link: Java Random Access File
How to create a zip file and how to compare zip size with normal text file
How to create a zip file and how to compare zip size with normal text file  Hi, how are you?I hope you are fine.I want program like how to create zip.../ZipCreateExample.shtml but when i verified the size of zip and normal file,normal file is showing
How to Compress file using DeflaterOutputStram class in java.
How to Compress file using DeflaterOutputStram class in java. In this tutorial, we will discuss  how to use DeflaterOutputStream class in java... will compressed the data of a file by using DeflaterOutputStream class
how to store image file and videofile in ms access database using java? - JDBC
how to store image file and videofile in ms access database using java?  how to store image file and video file in ms access database using java
How to include Two multi rows, one with a file Upload and another with normal fields, have problem while including both
How to include Two multi rows, one with a file Upload and another with normal fields, have problem while including both  How to include Two multi rows, one with a file Upload and another with normal fields, have problem while
how to forward select query result to jsp page using struts action class
how to forward select query result to jsp page using struts action class  how to forward select query result to jsp page using struts action class
How to access the image file from project folder itself while writing to pdf using itext?
How to access the image file from project folder itself while writing to pdf using itext?  I am writing a pdf using itext where i add a image... accomplish this.I am using simple java program to write the pdf.Not a servlet.Thanks
how to access windows registry information using java?
how to access windows registry information using java?  can any one help me how to access windows registry information using java
How to Compress file using Deflater class in java
How to Compress file using Deflater class in java. In this Example, we will discuss  how to use Deflater class in java. The Deflater class is used to compressed data by using ZLIB library. The Deflater class is available
How to ask a questions to you clearly with normal english?
How to ask a questions to you clearly with normal english?  hi, i want to know how should or can i may ask a question. send me some format... and click on the following link: [How to post code block correctly][1
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values are stored in database,the database name is registration. In another form i am
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values are stored in database,the database name is registration. In another form i am
Open a .doc file by click on the link using struts - Struts
Open a .doc file by click on the link using struts   I want to open a doc extension file when i click a link on jsp page .I know only about which is write in web.xml but not exactly know how i do this.Plz any one can help me
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  Hi all my Friends I have below code which insert a picture into M.S. Access Database But i m still not able to open this picture through Java using M.S. Access
Decompress file using Inflater class.
Example, we will explain how to decompress file using Inflater class. The Inflater...Decompress file using Inflater class. In this tutorial, we will define the use of Inflater class. The Inflater class provide support for Decompression using
How to Access MS Access in jar.
How to Access MS Access in jar.  how do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want... this ... i m able to access a Ms-access via JDBC but cant find the file wen
Understanding Struts Action Class
Understanding Struts Action Class       In this lesson I will show you how to use Struts Action Class and forward a jsp file through it.  What is Action Class? An Action
How to access session value using OGNL.
How to access session value using OGNL. In this example, you will see how to access value of session using OGNL expression language in struts2.  1-index.jsp <html> <head> <title>Access_Value_bean_from
how to read the .proprties file from struts - Struts
how to read the .proprties file from struts   errpr is :file not found exception:applicationresource.proprties file {system canot find file path"; How to set the file path.  Hi Friend, It seems that you haven't
How to write to file using FileWriter
How to write to file using FileWriter  hi, How to write to file using FileWriter thanks,   Hi, To writing in a file in Java program we... of the FileWriter class can be created using the following of its constructor i.e. FileWriter
How to write to file using FileOutputStream
How to write to file using FileOutputStream  Hi friends, Please help me in java program. How to write to file using FileOutputStream? thanks,   Hi, To write a file using FileOutputStream, we have to use
struts url problem in Switching module using SwitchAction class - Struts
struts url problem in Switching module using SwitchAction class  when i use SwitchAction class,it creates a problem take a examle when i go... and by using redirect tag i can not get the ArrayList Object because by using
How to zip a file using javascrip?
How to zip a file using javascrip?  hi.. can anyone tell me How to zip a file using javascrip
how to connect java with ms access using odbc in eclipse
how to connect java with ms access using odbc in eclipse  import java.sql.*; class AccessDatabase{ public static void main(String[] args... Access Driver (*.accdb)};DBQ=student.accdb","",""); Connection con
how to access the object of one frame on clicking a button without using this keyword
how to access the object of one frame on clicking a button without using this keyword  import java.awt.*; import java.awt.event.*; class Mybuttons1...) { System.exit(0); } }); } } class Myclass extends Frame implements
How to convert java BigDecimal to normal byte array not 2 s complement
How to convert java BigDecimal to normal byte array not 2 s complement  How to convert java BigDecimal to normal byte array not 2 s complement
how to send emails to many using jsp by connecting to ms access dabase.
how to send emails to many using jsp by connecting to ms access dabase.  Hi. I am trying to send multiple emails and the email ids are stored in a table in a msaccess database.I am using jsp for this.And finally there should
How to access Contacts from gmail using LDAP in JSP dropdown list
How to access Contacts from gmail using LDAP in JSP dropdown list  HI, I am creating a JSP page in which i have to make a dropdown box, and access gmail contacts in that drop downlist using LDAP. Can any one plz help me out
Advertisements
 

 

 

DMCA.com