I'm receiving the following error in Eclipse. My instructor was supposed to help me with this but I haven't heard back from him. I'm wondering if anyone here would be familiar??
Here is the error.
Exception in
thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an
applet parameter, or in an application resource file: java.naming.factory.initial
java.lang.NullPointerException
at lab.ConnectionPool.getConnection(ConnectionPool.java:33)
at lab.LocalMySQLCP.pooling(LocalMySQLCP.java:97)
at lab.LocalMySQLCP.openDB(LocalMySQLCP.java:106)
at lab.LocalMySQLCP.<init>(LocalMySQLCP.java:22)
at lab.LocalMySQLCP.main(LocalMySQLCP.java:53)
I'll post all the code below but I have a question about line 33 which is specified in the error.
Line 33 in the ConnectionPool class is
and the dataSource variable value is
The above code is taken from the book I'm working in It works for others in my class but my Eclipse is setup differently. It's setup in the same way I was told to set it up for work.
Is by any chance this line
java:/comp/env/jdbc has something to do with my java folder location? Currently my java is in C:\Development\Java\jdk1.8.0_71_64 . I have it setup to match my work computer setup. In the Environment variables of my computer I have JAVA_HOME set to C:\Development\Java\jdk1.8.0_71_64. I can't help but think maybe that's why I'm receiving this error? Maybe I need to change the value of the dataSource variable? I know that
JDBC is Java Database Connectivity (JDBC) so I'm probably wrong regarding this but I can't think of any other reason why it's not working for me and it does others.
Thank You for your help.
The ConnectionPool class which contains line 33 referenced above. Following this is the class ( with the remaining lines being referenced) . Last is the context.xml file that I have and that file is in the META-INF folder.
More details.
I'm using MySQL
My database schemas include a database name Country , sys, and testdata but my instructor says that I don't need to specify these database in the context.xml file.
My LocalMySQLCP class
Context.xml file