Skip to Content
avatar image
Former Member

jdbc error

hi,

if i am using backend ms access file in webdynpro java.if some error has come in running time

""com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of myname""**The my code part is

InitialContext ctx;

try {

ctx = new InitialContext();

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

Connection con = ds.getConnection();

String SelectStmt = "select name from Table1" ;

PreparedStatement stmt = con.prepareStatement(SelectStmt);

ResultSet resultSet = stmt.executeQuery();

while (resultSet.next())

{

IWDNodeElement element = wdContext.nodeNode().createElement();

element.setAttributeValue("name", resultSet.getString("name"));

wdContext.nodeNode().addElement(element);

}

}catch (Exception e) {

// TODO: handle exception

wdComponentAPI.getMessageManager().reportSuccess("ahdsjfahdsj " + e);

}

so send me correct solution

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 13, 2008 at 06:22 AM

    Hi Patrick,

    You have to specify a correct data source name, You can find it in Visual Administrator-> services->JDBC->Data Source Name..

    In lookup method, specify as

    DataSource ds = (DataSource)new InitialContext().lookup( "jdbc/<DSName>");
    

    Regards

    Vinod V

    Edited by: Vinod V on Aug 13, 2008 11:54 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 13, 2008 at 06:55 AM

    Hi,

    you can also do the following .

    -- Create an Enterprise application project and right click on the project a context menu will come up.

    Choose a option Data source Alias (Some thing like that)

    give any name and build and deploy the EAR file.

    Now in your webdynpro code you can LookUp the Alias like this ctx.lookup("jdbc/<DS Alias Name>")

    Hope this will help.

    Regards,

    Siddharth

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2008 at 09:25 AM

    Hi Patrick,

    check for JNDI name ..

    go to EjbProject->ejb-j2ee-engine.xml..double click on it

    n chk whethr u hav givn the same jndi name or nt??

    Regards,

    Khushboo

    Add comment
    10|10000 characters needed characters exceeded