Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 数据库连接过程中出现奇怪错误_Java_Xml_Jdbc_Junit - Fatal编程技术网

Java 数据库连接过程中出现奇怪错误

Java 数据库连接过程中出现奇怪错误,java,xml,jdbc,junit,Java,Xml,Jdbc,Junit,使用JUnit测试连接到数据库Java的类打印此错误: 错误:需要在环境或系统属性中指定类名,或作为小程序参数,或在应用程序资源文件中指定类名:java.naming.factory.initial 在一个主类中使用同一个类,我有相同的错误 在servlet中使用同一个类,并从浏览器中对其进行测试,它可以正常工作 我的数据库类与DB连接(错误在“ds.getConnection();”): 这是context.xml文件 <?xml version="1.0" encoding="UTF-

使用JUnit测试连接到数据库Java的类打印此错误:

错误:需要在环境或系统属性中指定类名,或作为小程序参数,或在应用程序资源文件中指定类名:java.naming.factory.initial

在一个主类中使用同一个类,我有相同的错误

在servlet中使用同一个类,并从浏览器中对其进行测试,它可以正常工作

我的数据库类与DB连接(错误在“ds.getConnection();”):

这是context.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Context>
    <Resource name="jdbc/mua"
        auth="Container"
        driverClassName="com.mysql.jdbc.Driver"
        type="javax.sql.DataSource"
        username="root"
        password="admin"
        url="jdbc:mysql://localhost:3306/mua?useSSL=false"/>
</Context>


您可能已经注册了应用程序容器可以自己执行的驱动程序(请参阅)…您可能已经注册了应用程序容器可以自己执行的驱动程序(请参阅)。。。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Context>
    <Resource name="jdbc/mua"
        auth="Container"
        driverClassName="com.mysql.jdbc.Driver"
        type="javax.sql.DataSource"
        username="root"
        password="admin"
        url="jdbc:mysql://localhost:3306/mua?useSSL=false"/>
</Context>