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

 
 


pradeep
how to access the messagresource.proprties filevalues in normal class file using struts
1 Answer(s)      3 years and 3 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");
}
}
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 Pages:
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
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
Difference between Normal Insert and BLOB insert
Difference between Normal Insert and BLOB insert  I have sql database... = System.Drawing.Image.FromStream(returnValue);** // Error if id=1 used i.e normal insert bytearray = imageToByteArray(MyImage); MyImage.Dispose(); if i use id 1 that is normal
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
Normal Distribution java program?
Normal Distribution java program?  For my last assignment i have... knows java: Write a program to tabulate the cumulative normal distribution F(z... is public class Distribution { public static double abs(double x) { if (x
Struts Tutorials
Struts application, specifically how you test the Action class. The Action class... object option. Using CASTOR for DB Access from STRUTS In this article we... the data access code written in the last article using JDBC 2. Discuss how to use
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 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
How Struts Works
Struts configuration file. Java bean is nothing but a class having getter... How Struts Works      ... to the context elements.  In the file WEB-INF/web.xml of struts
Access Excel file through JDBC
Access Excel file through JDBC In this section, you will learn how to access excel file through Jdbc and display records in JTable. As you know Excel comes with an ODBC driver, so we are using JDBC-ODBC bridge driver to connect jdbc
Access the User's node and Retrieve the Preference Information in Class
that how a Preference node can be access using a class object or a string and the string used to access a preference node is called path and same as a file path... will learn how to access the user's node and retrieve the stored information
Access value of array using OGNL in struts2.
Access value of array using OGNL in struts2. Here, you will see how to access value of  array in struts2 using OGNL.  1-index.jsp <%@taglib uri="/struts-tags" prefix="s"%><html> <
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
java - Struts
java   how can i get dynavalidation in my applications using struts... : *)The form beans of DynaValidatorForm are created by Struts and you configure in the Struts config : *)The Form Bean can be used
MS access
MS access  how do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want to access it via Code. Can anyone help me ? Please give reply urgent...   give me reply
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
Struts
Struts   1)in struts server side validations u are using programmatically validations and declarative validations? tell me which one is better ? 2) How to enable the validator plug-in file
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 access Enterprise Beans
How to access Enterprise Beans In this tutorial you will learn that how to access Enterprise Beans (applicable only to session beans not to message-driven... to clients. Using this view enterprise bean implemented class's or any super
how to access database in applet
how to access database in applet  HI... I'm having an applet where we... in the local system.. I created a policy file and also added that url...; public class QueryBuilderApplet extends JApplet { private JSObject win; private
multiple configurstion file in struts - Struts
multiple configurstion file in struts  Hi, Please tell me the solution. I have three configuration file as 'struts-config.xml','struts... in these three config file one by one respectively.So how I can place the code
Struts upload file - Framework
Struts upload file  Hi, I have upload a file from struts application.I am able to get the file name using getFileName() i created excel file and send to file upload struts..how to get the sheets and data in that sheets
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
Catching Normal Exceptions
Catching Normal Exceptions   ... to as normal exceptions.  We have already learned that to catch an exception...) { System.out.println(e.getMessage()); }  The code above shows how
Struts Configuration file - struts.xml
in the class path of your web application. Features of struts 2 configuration file... Struts Configuration file - struts.xml      ... explains you how best you can use the struts.xml file for you big projects
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
Want to access my Ms-access Db file which is placed inside the same Jar file
Want to access my Ms-access Db file which is placed inside the same Jar file  how do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want to access it via Code
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
Struts Articles
a sample Struts application to demonstrate how to extend Struts using each... security principle and discuss how Struts can be leveraged to address..., but the examples should work in any container. We will create a Struts plugin class
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program that stores the names... in an alphabetical order in a file and display it back on console. Do not use the RandomAccessFile class
Access properties of bean from request object using OGNL.
Access properties of bean from request object using OGNL. In this section, we will introduce you how to access beans properties from request object using...;%@taglib uri="/struts-tags" prefix="s"%> <html>
access data from mysql through struts
access data from mysql through struts  I am Pradeep Kundu. I am making a program in struts in which i want to access data from MySQL through struts. I am using Strut 1.3.8 , Netbean 6.7.1 and MySQL 5.5. In this program ,I want
what is struts? - Struts
what is struts?  What is struts?????how it is used n what... of the Struts framework is a flexible control layer based on standard technologies like Java... Commons packages. Struts encourages application architectures based on the Model 2
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I T"/>
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... using this jsp,but i want to CollegeAction class and CollegeForm class how to do...="file" name="file[]" multiple/> <html:submit value = "S U B M I 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
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
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
Struts 2 File Upload
Struts 2 File Upload       In this section you will learn how to write program in Struts 2 to upload the file... be used to upload the multipart file in your Struts 2 application. In this section you

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.