连接配置 # database type: mssql mysql dbtype=mssql # sqlserver config mssql_jdbcUrl = jdbc:sqlserver://localhost:1560;databaseName=his_yh mssql_driver = com.microsoft.sqlserver.jdbc.SQLServerDriver mssql_user = sa mssql_password =aaa123456789 devMode = true
lib
sqljdbc41.jar
调用代码:
configPlugin(Plugins me) { DruidPlugin druidPlugin=; (.get().toLowerCase().equals()) { System..println(+ .get()); druidPlugin = DruidPlugin(.get(), .get(), .get().trim());} { System..println(+ .get()); druidPlugin = DruidPlugin(.get(), .get(), .get().trim()); druidPlugin.setDriverClass(.get()); } me.add(druidPlugin); { druidPlugin.start(); ActiveRecordPlugin arp = ActiveRecordPlugin(, druidPlugin); arp.start(); } (Exception e){ System..println(+ e.getMessage() ); } me.add(MqttPlugin()); ReadConfig();} 报错: D:\java\jdk-12.0.1_x64\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:2278,suspend=y,server=n -javaagent:F:\IntelliJIdeaConfig\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "E:\work\HisServer\DataCore\DbCore\web\WEB-INF\classes;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\jfinal-4.3-bin-with-src.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\druid-1.0.29.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\log4j-1.2.16.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\mysql-connector-java-5.1.44-bin.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\jetty-server-2019.3.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\fastjson-1.2.7.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\cos-26Dec2008.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\activemq-client-5.15.10.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\mqtt-client-1.15.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\hawtbuf-1.11.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\org.eclipse.paho.client.mqttv3-1.2.2.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\json.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\sqljdbc41.jar;E:\work\HisServer\DataCore\DbCore\web\WEB-INF\lib\commons-codec-1.13.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.1\lib\idea_rt.jar" com.config.MainConfig Connected to the target VM, address: '127.0.0.1:2278', transport: 'socket' Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended Starting JFinal 4.3 Starting Jetty Server 9.4.z-SNAPSHOT on port: 80 MSSQL数据库地址:jdbc:sqlserver://1.255.255.246:1560;databaseName=his_yh 2019-11-27 09:38:06.939:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@aeab9a1{/,file:///E:/work/HisServer/DataCore/DbCore/web/,UNAVAILABLE} java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4098) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3160) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1461) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1525) at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:734) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1060) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1056) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104) at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:43) at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226) at com.config.MainConfig.configPlugin(MainConfig.java:162) at com.jfinal.core.Config.configPluginWithOrder(Config.java:70) at com.jfinal.core.Config.configJFinal(Config.java:59) at com.jfinal.core.JFinal.init(JFinal.java:61) at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63) at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138) at org.eclipse.jetty.server.Server.start(Server.java:416) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:383) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154) at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70) at com.jfinal.core.JFinal.start(JFinal.java:160) at com.jfinal.core.JFinal.start(JFinal.java:182) at com.config.MainConfig.main(MainConfig.java:50) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:565) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4098) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3160) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1461) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1525) at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:734) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1060) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1056) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104) at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:43) at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226) at com.config.MainConfig.configPlugin(MainConfig.java:162) at com.jfinal.core.Config.configPluginWithOrder(Config.java:70) at com.jfinal.core.Config.configJFinal(Config.java:59) at com.jfinal.core.JFinal.init(JFinal.java:61) at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63) at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138) at org.eclipse.jetty.server.Server.start(Server.java:416) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:383) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154) at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70) at com.jfinal.core.JFinal.start(JFinal.java:160) at com.jfinal.core.JFinal.start(JFinal.java:182) at com.config.MainConfig.main(MainConfig.java:50) Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4098) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3160) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1461) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1525) at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:734) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1060) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1056) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104) at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:43) at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226) at com.config.MainConfig.configPlugin(MainConfig.java:162) at com.jfinal.core.Config.configPluginWithOrder(Config.java:70) at com.jfinal.core.Config.configJFinal(Config.java:59) at com.jfinal.core.JFinal.init(JFinal.java:61) at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63) at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138) at org.eclipse.jetty.server.Server.start(Server.java:416) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:383) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154) at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70) at com.jfinal.core.JFinal.start(JFinal.java:160) at com.jfinal.core.JFinal.start(JFinal.java:182) at com.config.MainConfig.main(MainConfig.java:50) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:565) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 44 more Disconnected from the target VM, address: '127.0.0.1:2278', transport: 'socket' Process finished with exit code 130
项目:JFinal
System.out.println("MSSQL数据库地址:" + pConfigFile.get("mssql_jdbcUrl"));
// 1.实例化新的数据库连接池
druidPlugin = new DruidPlugin(pConfigFile.get("mssql_jdbcUrl"), pConfigFile.get("mssql_user"), pConfigFile.get("mssql_password").trim());
druidPlugin.setDriverClass(pConfigFile.get("mssql_driver"));
me.add(druidPlugin);
try {
// 2.启动连接池
druidPlugin.start();
// 3.实例化连接
ActiveRecordPlugin arp = new ActiveRecordPlugin("sqlConnect", druidPlugin);
// 4.启动该连接
arp.start();
}
catch (Exception e){
System.out.println("启动连接池失败:"+ e.getMessage() );
}