on 11-30-2007 10:29 AM
hai to everyone
i have issue with database coonection
we have default jbdbc source how to acces the data from it
in java webdynpro,how to give the url part correctly there
Shravan,
There's nothing specific to Web Dynpro here; just straight Java / JDBC. The example code below is for Oracle. Of course, if you want the connect to the backend R/3 database, the usual caveats and warnings about "going behind R/3's back" apply. RFC, web services, etc. are a better method for interfacing to an R/3 DB.
1. Load the driver, e.g., for Oracle:
Class.forName("oracle.jdbc.driver.OracleDriver");
2. Construct the URL for your database, e.g.,
String dbUrl = "jdbc:oracle:thin:@" + host + ":" + port + ":" + database;
e.g.,
String dbUrl = "jdbc:oracle:thin:@server.ip.address.com:1527:youDB";
3. Get a connection
Connection con = DriverManager.getConnection (dbUrl, userName, password);
4. Create a Statement
Statement stmt = con.createStatement();
5. Execute query
Result resultSet = stmt.executeQuery (query);
6. Close the result set, statement and connection in reverse order.
Good luck,
Kelly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
for connecting to backend database in NWDS
Use this code
Class.forName("com.sap.dbtech.jdbc.DriverSapDB");
String url="jdbc:sapdb://<HostID>/J2E?sqlmode=ORACLE";
Connection con=DriverManager.getConnection(url,"SAPJ2EDB","admin");
Then Write the code for Executing query
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.