on 10-14-2008 11:38 AM
Hello experts,
i`ve created a table from my NWDS and deploed it.
The table is based on following Columns:
- id
- Username
- password
- description
- furtherinformation
Now I want to connect from my WebDynproProject to this Database. Is there a step by step Documentation/Tutorial availiable.
Many Thanks!
Edited by: Marco Gennari on Oct 14, 2008 12:38 PM
Hi
for accesing the database u can also follow process.
1. first create a DSN in VA.
2. For getting a connection write a code in java class.
3. in your controller access the method and get connection.
4. once connection is established u can easily access alla the values from database.
for any code and clarification reply.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First of all - thank you for your quick answers.
I have now implemented folowing code im my wdDoInit:
"DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@Oracle_server_ip:Oracle port:SID of the Database","user_name","password");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("your query");"
The problem is that we are using a MaxDB Database. Is that OracleDriver compatibel???
Another Issue are the imports?
Which imports are necessary for
- Connection
- DriverManager
- Statement
.....
Many Thanks
marco
Hi,
The problem is that we are using a MaxDB Database. Is that OracleDriver compatibel???
No, You need to get the driver for MAX DB
Link for download and sample class
http://www.sapdb.org/sap_db_jdbc.htm
Another Issue are the imports?
Which imports are necessary for
Connection
DriverManager
Statement
All the above are part of jdbc api (java.sql. ).
Regards
Ayyapparaj
I have implemented the Connection as following but I Get following exception:
!!!!Object not found in lookup of SAPMJ2DB.!!!
Any ideas?
public void wdDoInit()
{
//@@begin wdDoInit()
try{
InitialContext ictx = new InitialContext();
DataSource dsc = (DataSource)ictx.lookup("jdbc/SAP""MJ2""DB");
Connection conn = dsc.getConnection();
String sqlStr = ("Select * FROM Test_Users");
Statement Stmt = conn.createStatement();
ResultSet rs = Stmt.executeQuery(sqlStr);
//as ResultSet in deinen Context schreiben
conn.close();
}catch(NamingException nex){
IWDMessageManager manager = wdComponentAPI.getMessageManager();
manager.reportException(nex.getMessage(),false);
}catch(SQLException sqlEx){
IWDMessageManager manager2 = wdComponentAPI.getMessageManager();
manager2.reportException("nx.getMessage,false);
}
//@@end
}
Hi,
No, is this necessary?
Yes if you are accessing it using DataSource
Other option is
String url = "jdbc:sapdb://" + host + "/" + dbname; // replacec host and dbname with yours
Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
Connection connection = DriverManager.getConnection (url, user, password);
Regards
Ayyapparaj
Thank you very much.
But now I get a classexception like
!!com.sap.dbtech.jdbc.DriverSapDB!!
I have importe following packages:
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.sap.dbtech.jdbc.DriverSapDB;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import mhp.com.portal.userlist.wdp.IPrivateTestUser
import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
Is there maybe a conflict so that DriverSapDb is not working???
Thanks
Sure.
Exeption:
com.sap.dbtech.jdbc.DriverSapDB
Source Code:
imports:
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import mhp.com.portal.userlist.wdp.IPrivateTestUser;
import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
public void wdDoInit()
{
//@@begin wdDoInit()
try{
Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
InitialContext ictx = new InitialContext();
String host = "xxxxxxxxx";
String dbname ="Test_Useres";
String url = "jdbc:sapdb://" + "localhost"+ "/" + "Test_Users";
java.sql.Connection conn =java.sql.DriverManager.getConnection (
"jdbc:sapdb://" + host + "/" + dbname);
String sqlStr = ("Select * FROM Test_Users");
Statement Stmt = conn.createStatement();
ResultSet rs = Stmt.executeQuery(sqlStr);
//as ResultSet in deinen Context schreiben
conn.close();
}catch(NamingException nex){
IWDMessageManager manager = wdComponentAPI.getMessageManager();
manager.reportException(nex.getMessage(),false);
}catch(SQLException sqlEx){
IWDMessageManager manager2 = wdComponentAPI.getMessageManager();
manager2.reportException(sqlEx.getMessage(),false);
}
catch(ClassNotFoundException classEx){
IWDMessageManager manager2 = wdComponentAPI.getMessageManager();
manager2.reportException("classexception"+classEx.getMessage(),false);
}
Edited by: Marco Gennari on Jan 20, 2009 5:10 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marco,
just check this link
thank
Edited by: Anup Bharti on Oct 14, 2008 12:48 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.