jdbc 相关问题

JDBC(Java DataBase Connectivity)是基本API,它通过使用Java编程语言执行SQL语句来实现与SQL数据库服务器的交互。

尝试连接到亚马逊红移驱动程序时出现“Caused by: java.lang.ClassNotFoundException: java.sql.SQLException”

下面是POM依赖 com.amazon.redshift redshift-jdbc42 下面是POM依赖 <dependency> <groupId>com.amazon.redshift</groupId> <artifactId>redshift-jdbc42</artifactId> <version>2.1.0.28</version> </dependency> 数据库连接代码包含在以下路径中 src -> main -> utils -> DatabaseConnection.java import java.sql.Driver; import java.util.Properties; import java.sql.*; public class DatabaseConnection { Logger logger = LoggerFactory.getLogger(DatabaseConnection.class); Connection connection = null; Properties props = new Properties(); public void getDataBaseConnection() { try { Class.forName("com.amazon.redshift.jdbc42.Driver"); logger.info("Connecting to database..."); String jdbcUrl = "jdbc:redshift://endpoint:port/dbname"; String dbUsername = "username"; String dbPassword = "password"; jdbcUrl = jdbcUrl + "?AccessKeyID=" + dbUsername + "&SecretAccessKey=" + dbPassword + "&DbUser=admin&ssl=true&tcpKeepAlive=true"; props.setProperty("ssl", "true"); props.setProperty("user", dbUsername); props.setProperty("password", dbPassword); connection = DriverManager.getConnection(jdbcUrl, props); if (connection != null) { logger.info("Connected to the database!"); } else { logger.info("Failed to make connection!"); } } catch (Exception e) { e.printStackTrace(); } } } 并在testng文件的以下路径中调用上面的代码 src->测试->java->测试->名称->sample_test.java import utils.DatabaseConnection; public class sample_test extends TestBase { DatabaseConnection dbconn = new DatabaseConnection(); @Test public void db_test(){ dbconn.getDataBaseConnection(); } } 执行上述操作后,出现以下错误 at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: org.apache.maven.plugin.MojoFailureException: Exception in provider at org.apache.maven.plugin.surefire.SurefirePlugin.assertNoException (SurefirePlugin.java:328) at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary (SurefirePlugin.java:318) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:892) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:755) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: org.apache.maven.surefire.booter.SurefireExecutionException: Exception in provider at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess (InPluginVMSurefireStarter.java:87) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1010) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:862) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:755) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: org.testng.TestNGException: Cannot instantiate class tests.name.sample_test at org.testng.internal.objects.InstanceCreator.newInstance (InstanceCreator.java:41) at org.testng.ITestObjectFactory.newInstance (ITestObjectFactory.java:18) at org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor (SimpleObjectDispenser.java:178) at org.testng.internal.objects.SimpleObjectDispenser.createInstance (SimpleObjectDispenser.java:87) at org.testng.internal.objects.SimpleObjectDispenser.dispense (SimpleObjectDispenser.java:40) at org.testng.internal.objects.GuiceBasedObjectDispenser.dispense (GuiceBasedObjectDispenser.java:28) at org.testng.internal.ClassImpl.getDefaultInstance (ClassImpl.java:106) at org.testng.internal.ClassImpl.getInstances (ClassImpl.java:136) at org.testng.TestClass.getInstances (TestClass.java:129) at org.testng.TestClass.initTestClassesAndInstances (TestClass.java:109) at org.testng.TestClass.init (TestClass.java:101) at org.testng.TestClass.<init> (TestClass.java:66) at org.testng.TestRunner.initMethods (TestRunner.java:465) at org.testng.TestRunner.init (TestRunner.java:333) at org.testng.TestRunner.init (TestRunner.java:286) at org.testng.TestRunner.<init> (TestRunner.java:176) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner (SuiteRunner.java:635) at org.testng.SuiteRunner.init (SuiteRunner.java:221) at org.testng.SuiteRunner.<init> (SuiteRunner.java:114) at org.testng.TestNG.createSuiteRunner (TestNG.java:1338) at org.testng.TestNG.createSuiteRunners (TestNG.java:1314) at org.testng.TestNG.runSuitesLocally (TestNG.java:1160) at org.testng.TestNG.runSuites (TestNG.java:1092) at org.testng.TestNG.run (TestNG.java:1060) at org.apache.maven.surefire.testng.TestNGExecutor.run (TestNGExecutor.java:132) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass (TestNGDirectoryTestSuite.java:112) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute (TestNGDirectoryTestSuite.java:99) at org.apache.maven.surefire.testng.TestNGProvider.invoke (TestNGProvider.java:147) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2 (ReflectionUtils.java:202) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke (ProviderFactory.java:155) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider (ProviderFactory.java:81) at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess (InPluginVMSurefireStarter.java:82) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1010) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:862) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:755) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: java.lang.reflect.InvocationTargetException at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62) at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance (Constructor.java:490) at org.testng.internal.objects.InstanceCreator.newInstance (InstanceCreator.java:38) at org.testng.ITestObjectFactory.newInstance (ITestObjectFactory.java:18) at org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor (SimpleObjectDispenser.java:178) at org.testng.internal.objects.SimpleObjectDispenser.createInstance (SimpleObjectDispenser.java:87) at org.testng.internal.objects.SimpleObjectDispenser.dispense (SimpleObjectDispenser.java:40) at org.testng.internal.objects.GuiceBasedObjectDispenser.dispense (GuiceBasedObjectDispenser.java:28) at org.testng.internal.ClassImpl.getDefaultInstance (ClassImpl.java:106) at org.testng.internal.ClassImpl.getInstances (ClassImpl.java:136) at org.testng.TestClass.getInstances (TestClass.java:129) at org.testng.TestClass.initTestClassesAndInstances (TestClass.java:109) at org.testng.TestClass.init (TestClass.java:101) at org.testng.TestClass.<init> (TestClass.java:66) at org.testng.TestRunner.initMethods (TestRunner.java:465) at org.testng.TestRunner.init (TestRunner.java:333) at org.testng.TestRunner.init (TestRunner.java:286) at org.testng.TestRunner.<init> (TestRunner.java:176) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner (SuiteRunner.java:635) at org.testng.SuiteRunner.init (SuiteRunner.java:221) at org.testng.SuiteRunner.<init> (SuiteRunner.java:114) at org.testng.TestNG.createSuiteRunner (TestNG.java:1338) at org.testng.TestNG.createSuiteRunners (TestNG.java:1314) at org.testng.TestNG.runSuitesLocally (TestNG.java:1160) at org.testng.TestNG.runSuites (TestNG.java:1092) at org.testng.TestNG.run (TestNG.java:1060) at org.apache.maven.surefire.testng.TestNGExecutor.run (TestNGExecutor.java:132) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass (TestNGDirectoryTestSuite.java:112) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute (TestNGDirectoryTestSuite.java:99) at org.apache.maven.surefire.testng.TestNGProvider.invoke (TestNGProvider.java:147) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2 (ReflectionUtils.java:202) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke (ProviderFactory.java:155) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider (ProviderFactory.java:81) at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess (InPluginVMSurefireStarter.java:82) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1010) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:862) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:755) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException at tests.name.sample_test.<init> (sample_test.java:30) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62) at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance (Constructor.java:490) at org.testng.internal.objects.InstanceCreator.newInstance (InstanceCreator.java:38) at org.testng.ITestObjectFactory.newInstance (ITestObjectFactory.java:18) at org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor (SimpleObjectDispenser.java:178) at org.testng.internal.objects.SimpleObjectDispenser.createInstance (SimpleObjectDispenser.java:87) at org.testng.internal.objects.SimpleObjectDispenser.dispense (SimpleObjectDispenser.java:40) at org.testng.internal.objects.GuiceBasedObjectDispenser.dispense (GuiceBasedObjectDispenser.java:28) at org.testng.internal.ClassImpl.getDefaultInstance (ClassImpl.java:106) at org.testng.internal.ClassImpl.getInstances (ClassImpl.java:136) at org.testng.TestClass.getInstances (TestClass.java:129) at org.testng.TestClass.initTestClassesAndInstances (TestClass.java:109) at org.testng.TestClass.init (TestClass.java:101) at org.testng.TestClass.<init> (TestClass.java:66) at org.testng.TestRunner.initMethods (TestRunner.java:465) at org.testng.TestRunner.init (TestRunner.java:333) at org.testng.TestRunner.init (TestRunner.java:286) at org.testng.TestRunner.<init> (TestRunner.java:176) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner (SuiteRunner.java:635) at org.testng.SuiteRunner.init (SuiteRunner.java:221) at org.testng.SuiteRunner.<init> (SuiteRunner.java:114) at org.testng.TestNG.createSuiteRunner (TestNG.java:1338) at org.testng.TestNG.createSuiteRunners (TestNG.java:1314) at org.testng.TestNG.runSuitesLocally (TestNG.java:1160) at org.testng.TestNG.runSuites (TestNG.java:1092) at org.testng.TestNG.run (TestNG.java:1060) at org.apache.maven.surefire.testng.TestNGExecutor.run (TestNGExecutor.java:132) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass (TestNGDirectoryTestSuite.java:112) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute (TestNGDirectoryTestSuite.java:99) at org.apache.maven.surefire.testng.TestNGProvider.invoke (TestNGProvider.java:147) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2 (ReflectionUtils.java:202) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke (ProviderFactory.java:155) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider (ProviderFactory.java:81) at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess (InPluginVMSurefireStarter.java:82) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1010) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:862) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:755) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: java.lang.ClassNotFoundException: java.sql.SQLException at java.net.URLClassLoader.findClass (URLClassLoader.java:476) at java.lang.ClassLoader.loadClass (ClassLoader.java:588) at java.lang.ClassLoader.loadClass (ClassLoader.java:521) at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass (IsolatedClassLoader.java:97) at tests.name.sample_test.<init> (sample_test.java:30) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62) at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance (Constructor.java:490) at org.testng.internal.objects.InstanceCreator.newInstance (InstanceCreator.java:38) at org.testng.ITestObjectFactory.newInstance (ITestObjectFactory.java:18) at org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor (SimpleObjectDispenser.java:178) at org.testng.internal.objects.SimpleObjectDispenser.createInstance (SimpleObjectDispenser.java:87) at org.testng.internal.objects.SimpleObjectDispenser.dispense (SimpleObjectDispenser.java:40) at org.testng.internal.objects.GuiceBasedObjectDispenser.dispense (GuiceBasedObjectDispenser.java:28) at org.testng.internal.ClassImpl.getDefaultInstance (ClassImpl.java:106) at org.testng.internal.ClassImpl.getInstances (ClassImpl.java:136) at org.testng.TestClass.getInstances (TestClass.java:129) at org.testng.TestClass.initTestClassesAndInstances (TestClass.java:109) at org.testng.TestClass.init (TestClass.java:101) at org.testng.TestClass.<init> (TestClass.java:66) at org.testng.TestRunner.initMethods (TestRunner.java:465) at org.testng.TestRunner.init (TestRunner.java:333) at org.testng.TestRunner.init (TestRunner.java:286) at org.testng.TestRunner.<init> (TestRunner.java:176) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner (SuiteRunner.java:635) at org.testng.SuiteRunner.init (SuiteRunner.java:221) at org.testng.SuiteRunner.<init> (SuiteRunner.java:114) at org.testng.TestNG.createSuiteRunner (TestNG.java:1338) at org.testng.TestNG.createSuiteRunners (TestNG.java:1314) at org.testng.TestNG.runSuitesLocally (TestNG.java:1160) at org.testng.TestNG.runSuites (TestNG.java:1092) at org.testng.TestNG.run (TestNG.java:1060) at org.apache.maven.surefire.testng.TestNGExecutor.run (TestNGExecutor.java:132) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass (TestNGDirectoryTestSuite.java:112) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute (TestNGDirectoryTestSuite.java:99) at org.apache.maven.surefire.testng.TestNGProvider.invoke (TestNGProvider.java:147) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2 (ReflectionUtils.java:202)) 注意:如果我使用 main() 方法执行,代码可以正常工作。但是用上面的配置运行就失败了。 它应该与数据库连接 您使用什么版本的 JDK 来运行该程序?

回答 1 投票 0

jdbc:DatabaseChangeListener 未显示事件更改

我正在实施 DCN 以获取有关插入表中的记录的通知。当我尝试插入记录时,无论是在应用程序内还是使用外部脚本,它都不会显示事件...

回答 1 投票 0

无法使用 Ktor 连接到 postgreSQL 数据库

我有一个示例 ktor 应用程序,我想在其中测试 PostgreSQL 连接。找不到我错过的点。 Docker 撰写文件正常,容器已启动。当我在本地运行时出现错误。它...

回答 1 投票 0

使用 postgres 和 springboot 时遇到问题

包 com.abc.calendar.calendarapi.model; 导入龙目岛。*; 导入 java.util.Date; 导入java.util.List; 导入java.util.Map; 导入 jakarta.persistence.Column; 导入 jakarta.persistence.Ent...

回答 0 投票 0

在ruby中使用sequel jdbc连接到microsoft sql server 2012 - 遇到错误com.microsoft.sqlserver.jdbc.SQLServerDriver not returned

我正在尝试使用sequel gem 连接到ruby 中的Microsoft SQL Server 2012 数据库。 这就是我所拥有的 要求“续集: 需要“activerecord-jdbcmssql-adapter” @db = Sequel.connect("jdbc:

回答 4 投票 0

在SpringBoot中自动装配bean时发出

我正在尝试使用 Spring boot JDBC 创建一个项目。 我已经用属性定义了所有必需的类。 但是当我运行该应用程序时,我收到 NullPointerException。 下面是代码:...

回答 1 投票 0

如何找到mysql-connector-java并将其添加到类路径

我有以下 Jenkins 版本和插件: 詹金斯2.426.3 数据库:247.v244b_d85f086d 数据库-mysql:63.va_0596d2b_1438 mysql-api:8.4.0-31.va_b_5ce7933762 这是我要连接的代码

回答 1 投票 0

Apache Ignite JDBC(可能是 ODBC 和瘦客户端)禁用设置不会阻止 JDBC 连接或查询

为了禁用通过 JDBC/ODBC/瘦客户端的访问,如文档中所述,我配置了 IgniteConfiguration#clientConnectorConfiguration 以设置 odbcEnabled、jdbcEnabled 和 ThinClientE...

回答 1 投票 0

使用 Denodo 驱动程序创建 Hikari 数据源和重复查询失败的问题

我正在尝试使用 Denodo 驱动程序创建 Hikari 数据源: @豆 数据源 dataSourceDenodo() 抛出 ClassNotFoundException { HikariDataSource dataSource = new HikariDataSource();

回答 1 投票 0

与 csv 文件相比,将 mysql 表转换为 Spark 数据集非常慢

我在 Amazon s3 中有 csv 文件,大小为 62mb(114 000 行)。我将其转换为 Spark 数据集,并从中获取前 500 行。代码如下; DataFrameReader df = 新的 DataFrameReader(

回答 2 投票 0

Oracle SQL 查询角色直至基于角色级别的报告经理 ID 并在列中更新

我正在尝试创建一个查询来获取每个员工的报告经理。但如果经理角色级别为 13,我们只应考虑该员工的汇报经理。 如果员工是

回答 1 投票 0

使用 Azure 服务主体和 MSAL 通过 PySPark JDBC 驱动程序从 DataBricks Python 笔记本连接到 MS SQL Server 时出现令牌(访问)错误

使用 Azure/DataBricks 服务主体和 MSAL 通过 PySPark JDBC 驱动程序从 DataBricks Python 笔记本连接到 MS SQL Server 时,如何解决令牌(Active Directory 访问)错误 (

回答 1 投票 0

pgjdbc中prepareThreshold = 5有什么好处?

pgjdbc中的prepareThreshold定义如下: 确定切换到使用服务器端准备好的语句之前所需的PreparedStatement 执行次数。德法...

回答 2 投票 0

OCI 无效操作ORA-01010

我正在运行一个批处理应用程序,该应用程序处理巨大的数据文件并将数据放入 Oracle 11g 数据库中。我使用的是 Java 1.6.20、ojdbc6 和 ucp11.2。间歇性地,我得到 ORA-01010 无效

回答 1 投票 0

java.lang.NoClassDefFoundError:java/sql/Driver?

我正在尝试构建一个登录注册网络应用程序,它本质上是让用户在数据库上注册,然后允许他们登录。我已经编写了所有代码,并且正在尝试连接我的程序...

回答 3 投票 0

使用Glassfish连接到h2数据库

我正在使用 Glassfish 应用服务器开发一个网络应用程序。 我已经安装了 H2 DB,现在尝试在 glassfish 中定义连接池,但在尝试 ping 数据库时失败。 这就是我...

回答 3 投票 0

升级到 Jakarta 时如何从 Java/JSP 连接到我的数据库?

我正在尝试将我 15 年前编写的代码迁移到新服务器。 其中一项更改是 javax.* 包命名更改为 jakarta.* 命名,作为 Oracle 将 Java EE 转移到 Ecl 的一部分...

回答 1 投票 0

使用 Java 虚拟线程管理 JDBC 连接

我们在 Java 17 中有一个服务,它在我们端执行逻辑,将请求发送到第三方系统。第三方系统的响应时间约为800-1400ms。 我们有一个 ThreadPoolExecutor ...

回答 1 投票 0

使用pyspark连接到MSSQL Server数据库

我是 pyspark 新手,正在尝试连接到 mssql 服务器数据库。详细信息如下: 当我运行我的脚本时,会打印出来。 ('处理表:', u'POL_ACTION_AMEND') ('表架构:'...

回答 1 投票 0

postgres jdbc 连接字符串与 ssl 证书(不带密钥库)

我们希望使用自签名证书通过 jdbc 连接 PostgreSQL 数据库。密钥库选项可用,但我想通过 jdbc 命令行传递证书。有什么选择吗

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.