Guest User

Untitled

a guest
Jul 31st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an
  2. applet parameter, or in an application resource file:
  3. java.naming.factory.initial at
  4. javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at
  5. javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at
  6. javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source) at
  7. javax.naming.InitialContext.lookup(Unknown Source)
  8.  
  9. public static Connection getDBConnection(String jndiName) throws NamingException, SQLException {
  10. Context initContext = new InitialContext();
  11. Context webContext = (Context)initContext.lookup(FISOProperties.getInstance().getProperty("jndi.lookup.base", "java:comp/env"));
  12. DataSource ds = (DataSource) webContext.lookup(jndiName);
  13. return ds.getConnection();
  14. }
  15.  
  16. <Resource name="java:comp/env" auth="Container" type="javax.sql.DataSource"
  17. maxActive="100" maxIdle="30" maxWait="10000" username="root" password="qet321"
  18. driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" />
Add Comment
Please, Sign In to add comment