Skip to Content
author's profile photo Former Member
Former Member

How can i get DB connetion from myself datasource....

HI!

J2EE engine default datasoure is connecting to SAP DB,i want to use sybase ,when i create a new datasource ,how can i get the connetion of sybase db,if anyone give the step and java code wirtten in WebDynpro...such as :

Context ctx = new InitialContext();
DataSource ds =  (DataSource)ctx.lookup("mySybase");

if (ds==null) {
	throw new Exception("DataSource is null");
}

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 21, 2006 at 07:28 AM

    Hi Ree,

    have you already data source and an alias for sybase DB on your server defined? When yes i think you sholud loking for data source with:

       ctx.lookup("jdbc/<your alias for synase>")

    Regards

    Bogdan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2006 at 02:23 AM

    hi,i met the same problem.

    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();

    }

    -


    i config JDBC connector in visual administration :

    DataSource name: sy_DS;

    DataSource aliases:sy_ds;

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

    JDBC version:1.X;

    driver class:com.sybase.jdbc.SybDriver;

    DataBase URL:jdbc:sybase:Tds:192.168.0.1:4001/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/sy2_ds");

    Connection c =ds.getConnection();

    <b><u> /*

    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.

    */</u></b>

    } catch (NamingException e) {

    e.printStackTrace();

    }

    -


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 07, 2006 at 01:34 AM

    Just wondering if you managed to get the datasource working?

    I just installed a SQL Anywhere database and was able to get the datasource configured/connected and now I'm having trouble with execution of a stored procedure. You said that you got the datasource connected, are you able to monitor the connection from within the Visual Administrator? What kind of SQL Engine did you specify? I had to specify "Vendor SQL" in order for the connection to initialize. When I try to close the connection, it blows up? Is it possible to use straight JDBC code or do you have to use the com.sap.sql.NativeSQLAccess classes?

    ...Scottd

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.