on 07-20-2006 11:28 AM
hi all
i am goutham
my dought is
what is the process to connect to database from WebDynpro ? please tell me the detailed procedure
thanks in advance
goutham.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think we don't have predefined process to connect to Database from Web Dynpro.
You can write all the logic in a Individual file (Normal Java Program - Helper Class). And use it wherever you want to connect to the Data Base.
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "127.0.0.1";
String portNumber = "1521";
String sid = "mydatabase";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "username";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
} catch (SQLException e) {
// Could not connect to the database
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Goutham,
First you have to determine the Database, then You have to create the Datasource,
Then datasource is a alias name.
Then you use the following code
InitialContext initialContext = new InitialContext();
DataSource dataSource = (DataSource)initialContext.lookup("jdbc/CareView");
java.sql.Connection conn = dataSource.getConnection();
Now you get the access to the database.
Then you will find the Table to manipulate
sample coding:
Then you can use the
Statement st=conn.createStatement();
Resultset rs=st.executeQuery("select * from <Table>);
then you can manipulate the resultset.
Hope this will help
Message was edited by: Saravanan K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.