1 Reply Latest reply: May 2, 2012 1:20 AM by 923724 RSS

    DataSourceDefinition

    923724
      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
          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