cancel
Showing results for 
Search instead for 
Did you mean: 

SOS: how to obtain a JDBC connection in webdynpro?

Former Member
0 Kudos

i can get an connection of sybase driver with this way(coder in webdynpro implementation):

-


......

try {

DriverManager.registerDriver(new SybDriver());

con =DriverManager.getConnection("jdbc:sybase:Tds:192.168.0.1:4000/dbName","username", "password");

} catch (SQLException e) {

e.printStackTrace();

}

-


but i wanna obtan a connection by jdbc connector.

following i config it in visual administrator:

DataSource name: sy_DS;

DataSource aliases:sy_ds;

Dirver name:sybase_driver(a name of i 'd registered a sybase jdbc1(jconn.jar) driver );

JDBC version:1.X;

driver class:com.sybase.jdbc.SybDriver;

DataBase URL:jdbc:sybase:Tds:192.168.0.1:4000/dbName;

user: username

password:password

===============================

follow coder is in webdynpro implementation to obtain a connecton:

....

try {

Context ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/sy_ds");

Connection c =ds.getConnection();

<i><b>/*

debug by step by step get a exeception here:

com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: com.sap.sql.log.OpenSQLException: Porting factory for ADAPTIVE SERVER ENTERPRISE database not defined.

*/</b></i>

} catch (NamingException e) {

e.printStackTrace();

}

-


Accepted Solutions (0)

Answers (1)

Answers (1)

former_member192029
Active Contributor
0 Kudos

Hi

Check your JDBC driver is registered. or else you have register it

1. Start the Visual Admin tool

2. In the tab Cluster, open the node of the server you want to check.

3. Open the node Services under the server you want to check.

4. Click on the entry ClassLoader Viewer under Services. 5. The components are displayed in the right window. Open the node Applications in the right window.

6. Look for the entry sap.com/com.sapportals.connectors.database and click on it.

Under sap.com/com.sapportals.connectors.database, your JDBC driver should be available

Cheers

Jawahar Govindaraj

Former Member
0 Kudos

hi,Jawahar Govindaraj

now i can obtan a connection just change "SQL engineer" to "Vendor SQL" in Visual Administator;

following is my coder (in webdynpro implementation):

-


....

try {

Context ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/sy_ds");

Connection c =ds.getConnection();

StringBuffer sb = new StringBuffer();

String sql = " select coulmn1 from mytable";//(1).

//String sql = " select coulmn1 from dbo.mytable";//(2).

PreparedStatement psmt = c.prepareStatement(sql);

<u>ResultSet rs = psmt.executeQuery();</u>

/*

debug step by step at here,an error come up:

<b>if sql statement is for 1,then errors is :</b>

<u>com.sybase.jdbc.SybSQLException: mytable not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).</u>

<b>if sql statement is for 2,then errors is :</b>

<u>com.sybase.jdbc.SybSQLException: myOwer.mytabler not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output)</u>

*/

if (rs.next()) {

sb.append(rs.getString(1));

}

} catch (NamingException e) {

e.printStackTrace();

}

addition:my database is using sybase.

-


Former Member
0 Kudos

i do as u said,in step 6 i click the entry of sap.com/com.sapportals.connectors.database,if only find one file is :<b>jdbcConnector.jar</b>. is that right?

i've registered an driver of sybase called "<u>sybase_drv</u>" in jdbc connector in Visual administrator,an sybase drive <u>jconn.jar</u> file under it.as what u said,the <u>jconn.jar</u> file should be appears under this directory?

expecting u reply.thanks a lot!

Former Member
0 Kudos

i solved it by my own!

it should set an initial connection number .