This discussion is archived
1 Reply Latest reply: May 1, 2012 11:20 PM by 923724 RSS

DataSourceDefinition

923724 Newbie
Currently Being Moderated
JDK: jdk1.7.0_03
Weblogc: 12c

Use below code to access mysql database, but mySqlDataSource always null, Please help me to figure it out.


@DataSourceDefinition(name = "java:module/CalculationLog",
className = "org.apache.derby.jdbc.ClientDataSource",
portNumber = 3306, serverName = "localhost", databaseName = "test", user = "root", password = "test")
public class AnnotationQuery
{
@Resource(lookup="java:module/CalculationLog")
DataSource mySqlDataSource;
}

Edited by: matthew on Apr 28, 2012 2:47 AM
  • 1. Re: DataSourceDefinition
    923724 Newbie
    Currently Being Moderated
    Seems @DataSourceDefinition only works while I put it above Servlet class:

    @DataSourceDefinition(...)
    public class AnnotationQueryServlet extends HttpServlet {
    ...
    }

    When I deploy this servlet into weblogic, weblogic will create a new JNDI name.
    But this JNDI name only can be seen at Service/Data Sources/Monitoring

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points