NutzCN Logo
问答 《入门手册》 3.10初始化数据 druid连接池报错
发布于 3217天前 作者 xzdking 4618 次浏览 复制 上一个帖子 下一个帖子
标签:
2016-3-2 11:44:32.191 INFO [localhost-startStop-1] NutFilter[nutz] starting ...
2016-3-2 11:44:32.212 INFO [localhost-startStop-1] [loc=file:/D:/Workspaces/Eclipse%20Mars.2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook/WEB-INF/lib/nutz-1.r.55.jar]not exist
2016-3-2 11:44:32.327 DEBUG [localhost-startStop-1] Locations for Scans:
[JarResourceLocation [jarPath=D:\Apache\apache-tomcat-7.0.64\bin\bootstrap.jar], JarResourceLocation [jarPath=D:\Program Files\Java\jdk1.7.0_80\lib\tools.jar], JarResourceLocation [jarPath=D:\Apache\apache-tomcat-7.0.64\bin\tomcat-juli.jar], ErrorResourceLocation [loc=file:/D:/Workspaces/Eclipse%20Mars.2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook/WEB-INF/lib/nutz-1.r.55.jar], FileSystemResourceLocation [root=D:\Program Files\eclipse]]
2016-3-2 11:44:32.462 DEBUG [localhost-startStop-1] Locations for Scans:
[FileSystemResourceLocation [root=D:\Workspaces\Eclipse Mars.2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\classes], JarResourceLocation [jarPath=D:\Apache\apache-tomcat-7.0.64\bin\bootstrap.jar], JarResourceLocation [jarPath=D:\Workspaces\Eclipse Mars.2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\mysql-connector-java-5.1.6.jar], JarResourceLocation [jarPath=D:\Workspaces\Eclipse Mars.2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\nutz-1.r.55.jar], JarResourceLocation [jarPath=D:\Program Files\Java\jdk1.7.0_80\lib\tools.jar], JarResourceLocation [jarPath=D:\Apache\apache-tomcat-7.0.64\bin\tomcat-juli.jar], ErrorResourceLocation [loc=file:/D:/Workspaces/Eclipse%20Mars.2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook/WEB-INF/lib/nutz-1.r.55.jar], JarResourceLocation [jarPath=D:\Workspaces\Eclipse Mars.2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\lib\druid-1.0.16.jar], FileSystemResourceLocation [root=D:\Program Files\eclipse]]
2016-3-2 11:44:32.466 DEBUG [localhost-startStop-1] MainModule: <com.nutz.MainModule>
2016-3-2 11:44:32.474 DEBUG [localhost-startStop-1] Loading by class org.nutz.mvc.impl.NutLoading
2016-3-2 11:44:32.477 INFO [localhost-startStop-1] Nutz Version : 1.r.55 
2016-3-2 11:44:32.477 INFO [localhost-startStop-1] Nutz.Mvc[nutz] is initializing ...
2016-3-2 11:44:32.477 DEBUG [localhost-startStop-1] Web Container Information:
2016-3-2 11:44:32.478 DEBUG [localhost-startStop-1]  - Default Charset : UTF-8
2016-3-2 11:44:32.479 DEBUG [localhost-startStop-1]  - Current . path  : D:\Program Files\eclipse\.
2016-3-2 11:44:32.479 DEBUG [localhost-startStop-1]  - Java Version    : 1.7.0_80
2016-3-2 11:44:32.479 DEBUG [localhost-startStop-1]  - File separator  : \
2016-3-2 11:44:32.479 DEBUG [localhost-startStop-1]  - Timezone        : Asia/Shanghai
2016-3-2 11:44:32.480 DEBUG [localhost-startStop-1]  - OS              : Windows 7 amd64
2016-3-2 11:44:32.480 DEBUG [localhost-startStop-1]  - ServerInfo      : Apache Tomcat/7.0.64
2016-3-2 11:44:32.480 DEBUG [localhost-startStop-1]  - Servlet API     : 3.0
2016-3-2 11:44:32.480 DEBUG [localhost-startStop-1]  - ContextPath     : /nutzbook
2016-3-2 11:44:32.481 DEBUG [localhost-startStop-1]  - context.tempdir : D:\Workspaces\Eclipse Mars.2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\nutzbook
2016-3-2 11:44:32.481 DEBUG [localhost-startStop-1] MainModule: <com.nutz.MainModule>
2016-3-2 11:44:32.482 DEBUG [localhost-startStop-1] >> app.root = D:/Workspaces/Eclipse Mars.2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook
2016-3-2 11:44:32.561 WARN [localhost-startStop-1] NONE Annotation-Class found!! Check your ioc configure!! packages=[com.nutzbook]
2016-3-2 11:44:32.530 DEBUG [localhost-startStop-1] Using 94 castor for Castors
2016-3-2 11:44:32.532 DEBUG [localhost-startStop-1] @IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args=["*js", "ioc/", "*anno", "com.nutzbook", "*tx"],init=[])
2016-3-2 11:44:32.553 DEBUG [localhost-startStop-1] Found 1 resource by src( ioc/ ) , regex( ^(.+[.])(js|json)$ )
2016-3-2 11:44:32.553 DEBUG [localhost-startStop-1] loading ioc js config from [dao.js]
2016-3-2 11:44:32.557 DEBUG [localhost-startStop-1] Loaded 2 bean define from path=[ioc/] --> [dataSource, dao]
2016-3-2 11:44:32.561 DEBUG [localhost-startStop-1] Found 0 resource by src( com/nutzbook/ ) , regex( ^.+[.]class$ )
2016-3-2 11:44:32.561 DEBUG [localhost-startStop-1] Loaded 5 bean define from reader --
[txREPEATABLE_READ, txREAD_COMMITTED, txNONE, txSERIALIZABLE, txREAD_UNCOMMITTED]
2016-3-2 11:44:32.564 INFO [localhost-startStop-1] NutIoc init begin ...
2016-3-2 11:44:32.566 INFO [localhost-startStop-1] ... NutIoc init complete
2016-3-2 11:44:32.567 DEBUG [localhost-startStop-1] MainModule: <com.nutz.MainModule>
2016-3-2 11:44:32.569 INFO [localhost-startStop-1] Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
2016-3-2 11:44:32.571 DEBUG [localhost-startStop-1] @Views(DefaultViewMaker.class)
2016-3-2 11:44:32.576 DEBUG [localhost-startStop-1] @ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
2016-3-2 11:44:32.584 DEBUG [localhost-startStop-1] module class location 'file:/D:/Workspaces/Eclipse%20Mars.2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/nutzbook/WEB-INF/classes/'
2016-3-2 11:44:32.584 INFO [localhost-startStop-1] [loc=D:\Workspaces\Eclipse%20Mars.2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\nutzbook\WEB-INF\classes]not exist
2016-3-2 11:44:32.584 DEBUG [localhost-startStop-1]  > scan 'com.nutz'
2016-3-2 11:44:32.587 DEBUG [localhost-startStop-1] Found 3 resource by src( com/nutz/ ) , regex( ^.+[.]class$ )
2016-3-2 11:44:32.589 WARN [localhost-startStop-1] None module classes found!!!
2016-3-2 11:44:32.589 WARN [localhost-startStop-1] None @At found in any modules class!!
2016-3-2 11:44:32.590 DEBUG [localhost-startStop-1] @Localization not define
2016-3-2 11:44:32.590 INFO [localhost-startStop-1] Setup application...
2016-3-2 11:44:32.591 DEBUG [localhost-startStop-1] Get 'dao'<interface org.nutz.dao.Dao>
2016-3-2 11:44:32.592 DEBUG [localhost-startStop-1]      >> Load definition name=dao
2016-3-2 11:44:32.593 DEBUG [localhost-startStop-1] Loading define for name=dao
2016-3-2 11:44:32.597 DEBUG [localhost-startStop-1] Found IocObject(dao) in IocLoader(JsonLoader@1206912021)
2016-3-2 11:44:32.597 DEBUG [localhost-startStop-1]      >> Make...'dao'<interface org.nutz.dao.Dao>
2016-3-2 11:44:32.609 DEBUG [localhost-startStop-1] Load class org.nutz.dao.impl.NutDao without AOP
2016-3-2 11:44:32.610 DEBUG [localhost-startStop-1] Save object 'dao' to [app] 
2016-3-2 11:44:32.612 DEBUG [localhost-startStop-1] Get 'dataSource'<>
2016-3-2 11:44:32.612 DEBUG [localhost-startStop-1]      >> Load definition name=dataSource
2016-3-2 11:44:32.612 DEBUG [localhost-startStop-1] Loading define for name=dataSource
2016-3-2 11:44:32.620 DEBUG [localhost-startStop-1] Found IocObject(dataSource) in IocLoader(JsonLoader@1206912021)
2016-3-2 11:44:32.620 DEBUG [localhost-startStop-1]      >> Make...'dataSource'<>
2016-3-2 11:44:32.634 DEBUG [localhost-startStop-1] Load class com.alibaba.druid.pool.DruidDataSource without AOP
2016-3-2 11:44:32.634 DEBUG [localhost-startStop-1] Save object 'dataSource' to [app] 

我是报错部分

三月 02, 2016 11:44:32 上午 com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker warn
警告: Cannot resolve com.mysq.jdbc.Connection.ping method.  Will use 'SELECT 1' instead.
java.lang.NullPointerException
at com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker.<init>(MySqlValidConnectionChecker.java:50)
at com.alibaba.druid.pool.DruidDataSource.initValidConnectionChecker(DruidDataSource.java:892)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:608)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:72)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:229)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:148)
at com.nutz.MainSetup.init(MainSetup.java:27)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:276)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:120)
at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
三月 02, 2016 11:44:32 上午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited

2016-3-2 11:44:32.675 DEBUG [localhost-startStop-1] Get 'dataSource'<>
2016-3-2 11:44:32.681 DEBUG [localhost-startStop-1] NutDao[_selfId=0] init ...
2016-3-2 11:44:32.702 INFO [localhost-startStop-1] Init file-pool by: C:\Users\Administrator/.nutz/tmp/dao/ [200000]
2016-3-2 11:44:32.702 DEBUG [localhost-startStop-1] file-pool.home: 'C:\Users\Administrator\.nutz\tmp\dao'
2016-3-2 11:44:32.703 INFO [localhost-startStop-1] file-pool.cursor: 0
2016-3-2 11:44:32.710 DEBUG [localhost-startStop-1] Jdbcs init complete
2016-3-2 11:44:32.710 INFO [localhost-startStop-1] Get Connection from DataSource for JdbcExpert, if I lock at here, check your database server and configure
2016-3-2 11:44:32.872 DEBUG [localhost-startStop-1] JDBC Driver --> mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
2016-3-2 11:44:32.872 DEBUG [localhost-startStop-1] JDBC Name   --> MySQL-AB JDBC Driver
2016-3-2 11:44:32.872 DEBUG [localhost-startStop-1] JDBC URL    --> jdbc:mysql://127.0.0.1:3306/nutzbook
2016-3-2 11:44:32.876 DEBUG [localhost-startStop-1] Mysql : character_set_client=utf8
2016-3-2 11:44:32.877 DEBUG [localhost-startStop-1] Mysql : character_set_connection=utf8
2016-3-2 11:44:32.877 DEBUG [localhost-startStop-1] Mysql : character_set_database=utf8
2016-3-2 11:44:32.877 DEBUG [localhost-startStop-1] Mysql : character_set_filesystem=binary
2016-3-2 11:44:32.877 DEBUG [localhost-startStop-1] Mysql : character_set_results=
2016-3-2 11:44:32.878 DEBUG [localhost-startStop-1] Mysql : character_set_server=utf8
2016-3-2 11:44:32.878 DEBUG [localhost-startStop-1] Mysql : character_set_system=utf8
2016-3-2 11:44:32.878 DEBUG [localhost-startStop-1] Mysql : character_sets_dir=C:\Program Files\MySQL\MySQL Server 5.6\share\charsets\
2016-3-2 11:44:32.879 DEBUG [localhost-startStop-1] Mysql : database=nutzbook
2016-3-2 11:44:32.879 DEBUG [localhost-startStop-1] Mysql : user=root@localhost
2016-3-2 11:44:32.889 DEBUG [localhost-startStop-1] Database info --> MYSQL:[MySQL - 5.6.25-log]
2016-3-2 11:44:32.895 DEBUG [localhost-startStop-1] Found 0 resource by src( com/nutzbook/ ) , regex( ^.+[.]class$ )
2016-3-2 11:44:32.948 DEBUG [localhost-startStop-1] SELECT COUNT(*) FROM t_user 
2016-3-2 11:44:32.963 DEBUG [localhost-startStop-1] INSERT INTO t_user(username,password,salt,ct,ut) VALUES(?,?,?,?,?) 
    |     1 |      2 |    3 |                   4 |                   5 |
    |-------|--------|------|---------------------|---------------------|
    | admin | 123456 | NULL | 2016-03-02 11:44:32 | 2016-03-02 11:44:32 |
  For example:> "INSERT INTO t_user(username,password,salt,ct,ut) VALUES('admin','123456',NULL,'2016-03-02 11:44:32','2016-03-02 11:44:32') "
2016-3-2 11:44:33.58 INFO [localhost-startStop-1] Nutz.Mvc[nutz] is up in 577ms
三月 02, 2016 11:44:33 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
三月 02, 2016 11:44:33 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
三月 02, 2016 11:44:33 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 1984 ms

数据正常插入数据库!

求教 谢谢!

7 回复

mysql驱动更新到最新即可

@wendal 是什么原因呢?

mysql驱动版本低,没有ping方法,所以druid提示一下而已

我项目的mysql-connector-java.jar 用的是5.1.38版本,再更新就是6.0.2,试了下这个版本,链接低版本的mysql会报别的错,高版本的mysql一样报以上错误信息:
2016-05-06 21:18:48,063 [WARN ] or.MySqlValidConnectionChecker - Cannot resolve com.mysq.jdbc.Connection.ping method. Will use 'SELECT 1' instead.
java.lang.NullPointerException
at com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker.(MySqlValidConnectionChecker.java:50)
at com.alibaba.druid.pool.DruidDataSource.initValidConnectionChecker(DruidDataSource.java:944)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:659)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:986)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:982)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:102)
at org.nutz.trans.Trans.getConnectionAuto(Trans.java:263)
at org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:106)
at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:174)
at org.nutz.dao.impl.NutDao.(NutDao.java:112)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:114)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209)
at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:26)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:235)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:153)
at com.qianlima.task.StartValidTemplateFaultFilterTask.main(StartValidTemplateFaultFilterTask.java:26)
2016-05-06 21:18:48,075 [INFO ] aba.druid.pool.DruidDataSource - {dataSource-1} inited

你们项目里正常?!

看启动日志里面的

2016-3-2 11:44:32.872 DEBUG [localhost-startStop-1] JDBC Driver --> mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )

这里显示的才是真正的版本号. 仔细检查版本号, 5.1.30+以上肯定ok

mysql官方链接 https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-usagenotes-j2ee-concepts-connection-pooling.html

@wendal 刚从maven repository 下载最新的,不报错了,确实是jar问题,可能是之前用的是6.0.2有问题,替换jar包替换成更低版本的了。 谢谢!

添加回复
请先登陆
回到顶部