gpt4 book ai didi

java - 将 JDBC 驱动程序连接到 MSSQL 数据库时出现问题

转载 作者:行者123 更新时间:2023-11-30 03:17:33 27 4
gpt4 key购买 nike

我们有一个 Java Web 应用程序,我遇到了一些 JDBC 问题。去年,在 Java 7 上,我们使用 sqljdbc4.jar 连接到同一网络上另一台服务器上的 SQL 数据库没有问题。今年我们将应用程序升级到了 Java 8,这就是问题出现的时候。我们将 JDBC 版本更新为 4.2 (sqljdbc42.jar)。 .jar 文件包含在我们的构建路径中,并且该文件在一年前有效。我们在 Eclipse-Luna IDE 中使用 JBOSS 7.0。

现在,当我们尝试使用 JDBC 时,我们会收到 java.lang.ClassNotFoundException。

Connection conn = null;
String db_hostname = "test.fake.com";
String db_portNumber = "1433";
String db_name = "db";
String db_userid = "user";
String db_password = "password";
String db_final_string = "jdbc:sqlserver://" + db_hostname + ":" + db_portNumber + ";databaseName=" + db_name;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection(_db_final_string, _db_userid, _db_password);

这是由于 Class.forName() 导致的错误:

15:30:12,919 ERROR [stderr] (http--0.0.0.0-9091-5) java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver from [Module "deployment.irw-ear.ear:main" from Service Module Loader]

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.Class.forName0(Native Method)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.Class.forName(Unknown Source)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.delegate.IAContentDelegate.getIADataFromClient(IAContentDelegate.java:1776)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.delegate.IAContentDelegate.getIAData(IAContentDelegate.java:1751)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.ejb.IAContentBean.getIAData(IAContentBean.java:188)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.reflect.Method.invoke(Unknown Source)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.ejb.BaseBean.intercept(BaseBean.java:27)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.reflect.Method.invoke(Unknown Source)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:67)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.ejb.BaseBean.intercept(BaseBean.java:27)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)

15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.reflect.Method.invoke(Unknown Source)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:67)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:50)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:211)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:284)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.api.IIAContent$$$view10.getIAData(Unknown Source)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.IAContentView.getIADataDubois(IAContentView.java:123)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.IAContentView.insertExternalData(IAContentView.java:98)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.IAContentView.doPost(IAContentView.java:62)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.filter.IRWFilter.filterRequest(IRWFilter.java:176)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.filter.IRWFilter.doFilter(IRWFilter.java:97)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)

15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)

15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.Thread.run(Unknown Source)

如果任何人都可以提供有关如何正确配置此选项的任何见解,那将是最有帮助的,因为我们已经尝试了几种调整组合。

最佳答案

JBoss AS 7 与 Java 8 不兼容*。您需要更新到 WildFly 8/9 .

<小时/>

注释

* 查看更多信息 AS 7 on Java 8 .

关于java - 将 JDBC 驱动程序连接到 MSSQL 数据库时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32212770/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com