NutzCN Logo
问答 Sqls执行语句返回空值
发布于 2648天前 作者 qq_4945a577 1568 次浏览 复制 上一个帖子 下一个帖子
标签:
import org.apache.log4j.Logger;
import org.junit.Test;
import org.nutz.dao.Dao;
import org.nutz.dao.SqlManager;
import org.nutz.dao.Sqls;
import org.nutz.dao.impl.FileSqlManager;
import org.nutz.dao.impl.NutDao;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.combo.ComboIocLoader;
import org.visual.tongyong.bean.WccProvinceQueryView;

import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;

public class Test2 {
    Logger log = Logger.getLogger(Test2.class);

    @Test
    public void test1() throws ClassNotFoundException {

        Ioc ioc = new NutIoc(new ComboIocLoader("*js", "ioc/",
                "*anno", "net.nutz.wcc",
                "*tx",
                "*async"));

        DataSource ds = ioc.get(DataSource.class);
        Dao dao = new NutDao(ds);
        List<WccProvinceQueryView> list = new ArrayList<>();
        SqlManager sqlm = new FileSqlManager("sqls/");
        Sql sql = sqlm.create("WarningData.query2");
        Sql sql2= Sqls.create("SELECT count(*) FROM wcc_province_query");
        dao.execute(sql);
        int i = sql2.getInt();
        log.info(list.size()+1);

    }
}

D:\Software_Develops\JDK\bin\java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:58447,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -Dfile.encoding=UTF-8 -classpath "D:\Software_Develops\IntelliJ IDEA 2017.1\lib\idea_rt.jar;D:\Software_Develops\IntelliJ IDEA 2017.1\plugins\junit\lib\junit-rt.jar;D:\Software_Develops\IntelliJ IDEA 2017.1\plugins\junit\lib\junit5-rt.jar;D:\Software_Develops\JDK\jre\lib\charsets.jar;D:\Software_Develops\JDK\jre\lib\deploy.jar;D:\Software_Develops\JDK\jre\lib\ext\access-bridge-64.jar;D:\Software_Develops\JDK\jre\lib\ext\cldrdata.jar;D:\Software_Develops\JDK\jre\lib\ext\dnsns.jar;D:\Software_Develops\JDK\jre\lib\ext\jaccess.jar;D:\Software_Develops\JDK\jre\lib\ext\jfxrt.jar;D:\Software_Develops\JDK\jre\lib\ext\localedata.jar;D:\Software_Develops\JDK\jre\lib\ext\nashorn.jar;D:\Software_Develops\JDK\jre\lib\ext\sunec.jar;D:\Software_Develops\JDK\jre\lib\ext\sunjce_provider.jar;D:\Software_Develops\JDK\jre\lib\ext\sunmscapi.jar;D:\Software_Develops\JDK\jre\lib\ext\sunpkcs11.jar;D:\Software_Develops\JDK\jre\lib\ext\zipfs.jar;D:\Software_Develops\JDK\jre\lib\javaws.jar;D:\Software_Develops\JDK\jre\lib\jce.jar;D:\Software_Develops\JDK\jre\lib\jfr.jar;D:\Software_Develops\JDK\jre\lib\jfxswt.jar;D:\Software_Develops\JDK\jre\lib\jsse.jar;D:\Software_Develops\JDK\jre\lib\management-agent.jar;D:\Software_Develops\JDK\jre\lib\plugin.jar;D:\Software_Develops\JDK\jre\lib\resources.jar;D:\Software_Develops\JDK\jre\lib\rt.jar;E:\Work\InstelliJIDEAR_WorkSpaceNo.1\visualdisplay\target\test-classes;E:\Work\InstelliJIDEAR_WorkSpaceNo.1\visualdisplay\target\classes;D:\Software_Develops\maven\Repository\org\nutz\nutz\1.r.62\nutz-1.r.62.jar;D:\Software_Develops\maven\Repository\org\apache\shiro\shiro-core\1.3.2\shiro-core-1.3.2.jar;D:\Software_Develops\maven\Repository\org\apache\shiro\shiro-web\1.3.2\shiro-web-1.3.2.jar;D:\Software_Develops\maven\Repository\org\apache\shiro\shiro-ehcache\1.3.2\shiro-ehcache-1.3.2.jar;D:\Software_Develops\maven\Repository\net\sf\ehcache\ehcache-core\2.5.3\ehcache-core-2.5.3.jar;D:\Software_Develops\maven\Repository\org\nutz\nutz-plugins-daocache\1.r.62\nutz-plugins-daocache-1.r.62.jar;D:\Software_Develops\maven\Repository\net\sf\ehcache\ehcache\2.10.4\ehcache-2.10.4.jar;D:\Software_Develops\maven\Repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;D:\Software_Develops\maven\Repository\org\slf4j\slf4j-log4j12\1.7.25\slf4j-log4j12-1.7.25.jar;D:\Software_Develops\maven\Repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;D:\Software_Develops\maven\Repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\Software_Develops\maven\Repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\Software_Develops\maven\Repository\jstl\jstl\1.2\jstl-1.2.jar;D:\Software_Develops\maven\Repository\org\apache\commons\commons-email\1.5\commons-email-1.5.jar;D:\Software_Develops\maven\Repository\com\sun\mail\javax.mail\1.5.6\javax.mail-1.5.6.jar;D:\Software_Develops\maven\Repository\javax\mail\mail\1.4\mail-1.4.jar;D:\Software_Develops\maven\Repository\javax\activation\activation\1.1\activation-1.1.jar;D:\Software_Develops\maven\Repository\cn\apiclub\tool\simplecaptcha\1.2.2\simplecaptcha-1.2.2.jar;D:\Software_Develops\maven\Repository\org\nutz\nutz-integration-quartz\1.r.62\nutz-integration-quartz-1.r.62.jar;D:\Software_Develops\maven\Repository\org\nutz\nutz-integration-shiro\1.r.62\nutz-integration-shiro-1.r.62.jar;D:\Software_Develops\maven\Repository\org\slf4j\jcl-over-slf4j\1.7.24\jcl-over-slf4j-1.7.24.jar;D:\Software_Develops\maven\Repository\org\nutz\nutz-plugins-apidoc\1.r.62\nutz-plugins-apidoc-1.r.62.jar;D:\Software_Develops\maven\Repository\redis\clients\jedis\2.8.1\jedis-2.8.1.jar;D:\Software_Develops\maven\Repository\org\apache\commons\commons-pool2\2.4.2\commons-pool2-2.4.2.jar;D:\Software_Develops\maven\Repository\org\nutz\nutz-integration-jedis\1.r.63-SNAPSHOT\nutz-integration-jedis-1.r.63-20170918.120646-74.jar;D:\Software_Develops\maven\Repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;D:\Software_Develops\maven\Repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;D:\Software_Develops\maven\Repository\org\apache\maven\plugins\maven-resources-plugin\2.4.3\maven-resources-plugin-2.4.3.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-plugin-api\2.0.6\maven-plugin-api-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-project\2.0.6\maven-project-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-profile\2.0.6\maven-profile-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-artifact-manager\2.0.6\maven-artifact-manager-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-plugin-registry\2.0.6\maven-plugin-registry-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-core\2.0.6\maven-core-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-file\1.0-beta-2\wagon-file-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-plugin-parameter-documenter\2.0.6\maven-plugin-parameter-documenter-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-http-lightweight\1.0-beta-2\wagon-http-lightweight-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-http-shared\1.0-beta-2\wagon-http-shared-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\jtidy\jtidy\4aug2000r7-dev\jtidy-4aug2000r7-dev.jar;D:\Software_Develops\maven\Repository\xml-apis\xml-apis\1.0.b2\xml-apis-1.0.b2.jar;D:\Software_Develops\maven\Repository\org\apache\maven\reporting\maven-reporting-api\2.0.6\maven-reporting-api-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\doxia\doxia-sink-api\1.0-alpha-7\doxia-sink-api-1.0-alpha-7.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-provider-api\1.0-beta-2\wagon-provider-api-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-repository-metadata\2.0.6\maven-repository-metadata-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-error-diagnostics\2.0.6\maven-error-diagnostics-2.0.6.jar;D:\Software_Develops\maven\Repository\commons-cli\commons-cli\1.0\commons-cli-1.0.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-ssh-external\1.0-beta-2\wagon-ssh-external-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-ssh-common\1.0-beta-2\wagon-ssh-common-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-plugin-descriptor\2.0.6\maven-plugin-descriptor-2.0.6.jar;D:\Software_Develops\maven\Repository\org\codehaus\plexus\plexus-interactivity-api\1.0-alpha-4\plexus-interactivity-api-1.0-alpha-4.jar;D:\Software_Develops\maven\Repository\org\apache\maven\wagon\wagon-ssh\1.0-beta-2\wagon-ssh-1.0-beta-2.jar;D:\Software_Develops\maven\Repository\com\jcraft\jsch\0.1.27\jsch-0.1.27.jar;D:\Software_Develops\maven\Repository\classworlds\classworlds\1.1\classworlds-1.1.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-artifact\2.0.6\maven-artifact-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-settings\2.0.6\maven-settings-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-model\2.0.6\maven-model-2.0.6.jar;D:\Software_Develops\maven\Repository\org\apache\maven\maven-monitor\2.0.6\maven-monitor-2.0.6.jar;D:\Software_Develops\maven\Repository\org\codehaus\plexus\plexus-container-default\1.0-alpha-9-stable-1\plexus-container-default-1.0-alpha-9-stable-1.jar;D:\Software_Develops\maven\Repository\org\codehaus\plexus\plexus-utils\2.0.5\plexus-utils-2.0.5.jar;D:\Software_Develops\maven\Repository\org\apache\maven\shared\maven-filtering\1.0-beta-4\maven-filtering-1.0-beta-4.jar;D:\Software_Develops\maven\Repository\org\sonatype\plexus\plexus-build-api\0.0.4\plexus-build-api-0.0.4.jar;D:\Software_Develops\maven\Repository\org\codehaus\plexus\plexus-interpolation\1.13\plexus-interpolation-1.13.jar;D:\Software_Develops\maven\Repository\mysql\mysql-connector-java\5.1.40\mysql-connector-java-5.1.40.jar;D:\Software_Develops\maven\Repository\org\quartz-scheduler\quartz\2.2.1\quartz-2.2.1.jar;D:\Software_Develops\maven\Repository\c3p0\c3p0\0.9.1.1\c3p0-0.9.1.1.jar;D:\Software_Develops\maven\Repository\org\quartz-scheduler\quartz-jobs\2.2.1\quartz-jobs-2.2.1.jar;D:\Software_Develops\maven\Repository\com\alibaba\druid\1.0.27\druid-1.0.27.jar;D:\Software_Develops\JDK\lib\jconsole.jar;D:\Software_Develops\JDK\lib\tools.jar;D:\Software_Develops\maven\Repository\junit\junit\4.12\junit-4.12.jar;D:\Software_Develops\maven\Repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 @w@C:\Users\lenovo\AppData\Local\Temp\idea_working_dirs_junit.tmp @C:\Users\lenovo\AppData\Local\Temp\idea_junit.tmp
Connected to the target VM, address: '127.0.0.1:58447', transport: 'socket'
2017-09-27 09:34:41,263 org.nutz.resource.Scans.printLocations(Scans.java:521) DEBUG - Locations count=100 time use 141ms
2017-09-27 09:34:41,294 org.nutz.resource.Scans.scan(Scans.java:274) DEBUG - Found 3 resource by src( ioc/ ) , regex( ^(.+[.])(js|json)$ )
2017-09-27 09:34:41,294 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49) DEBUG - loading [dao.js]
2017-09-27 09:34:41,372 org.nutz.castor.Castors.reload(Castors.java:115) DEBUG - Using 95 castor for Castors
2017-09-27 09:34:41,388 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49) DEBUG - loading [ehcache.js]
2017-09-27 09:34:41,388 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49) DEBUG - loading [mail.js]
2017-09-27 09:34:41,388 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:57) DEBUG - Loaded 8 bean define from path=[ioc/] --> [dao, cacheProvider, emailAuthenticator, htmlEmail, cacheExecutor, conf, dataSource, cacheManager]
2017-09-27 09:34:41,404 org.nutz.resource.Scans.scan(Scans.java:274) DEBUG - Found 0 resource by src( net/nutz/wcc/ ) , regex( ^.+[.]class$ )
2017-09-27 09:34:41,404 org.nutz.ioc.loader.annotation.AnnotationIocLoader.<init>(AnnotationIocLoader.java:57) WARN  - NONE Annotation-Class found!! Check your ioc configure!! packages=[net.nutz.wcc]
2017-09-27 09:34:41,419 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:40) DEBUG - Loaded 5 bean define from reader --
[txREPEATABLE_READ, txSERIALIZABLE, txNONE, txREAD_UNCOMMITTED, txREAD_COMMITTED]
2017-09-27 09:34:41,482 org.nutz.ioc.aop.SimpleAopMaker.<init>(SimpleAopMaker.java:79) DEBUG - Load AopConfigure for anno=org.nutz.aop.interceptor.async.Async by type=org.nutz.aop.interceptor.async.AsyncAopIocLoader
2017-09-27 09:34:41,482 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:98) INFO  - NutIoc init begin ...
2017-09-27 09:34:41,482 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:115) INFO  - ... NutIoc init complete
2017-09-27 09:34:41,497 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'dataSource'<interface javax.sql.DataSource>
2017-09-27 09:34:41,497 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get '$aop_async'<interface org.nutz.ioc.aop.config.AopConfigration>
2017-09-27 09:34:41,497 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:177) DEBUG - 	 >> Load definition name=$aop_async
2017-09-27 09:34:41,497 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject($aop_async) in AsyncAopIocLoader@464887938
2017-09-27 09:34:41,497 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209) DEBUG - 	 >> Make...'$aop_async'<interface org.nutz.ioc.aop.config.AopConfigration>
2017-09-27 09:34:41,497 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) DEBUG - Save object '$aop_async' to [app] 
2017-09-27 09:34:41,513 org.nutz.ioc.aop.SimpleAopMaker.<init>(SimpleAopMaker.java:79) DEBUG - Load AopConfigure for anno=org.nutz.ioc.aop.Aop by type=org.nutz.ioc.aop.config.impl.AnnotationAopConfigration
2017-09-27 09:34:41,513 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:177) DEBUG - 	 >> Load definition name=dataSource
2017-09-27 09:34:41,513 org.nutz.ioc.loader.map.MapLoader.load(MapLoader.java:67) DEBUG - Loading define for name=dataSource
2017-09-27 09:34:41,544 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject(dataSource) in JsonLoader(paths=[ioc/])
2017-09-27 09:34:41,544 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209) DEBUG - 	 >> Make...'dataSource'<interface javax.sql.DataSource>
2017-09-27 09:34:41,575 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) DEBUG - Load class com.alibaba.druid.pool.DruidDataSource without AOP
2017-09-27 09:34:41,575 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) DEBUG - Save object 'dataSource' to [app] 
2017-09-27 09:34:41,575 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'conf'<>
2017-09-27 09:34:41,575 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:177) DEBUG - 	 >> Load definition name=conf
2017-09-27 09:34:41,575 org.nutz.ioc.loader.map.MapLoader.load(MapLoader.java:67) DEBUG - Loading define for name=conf
2017-09-27 09:34:41,607 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject(conf) in JsonLoader(paths=[ioc/])
2017-09-27 09:34:41,607 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209) DEBUG - 	 >> Make...'conf'<>
2017-09-27 09:34:41,607 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) DEBUG - Load class org.nutz.ioc.impl.PropertiesProxy without AOP
2017-09-27 09:34:41,607 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) DEBUG - Save object 'conf' to [app] 
2017-09-27 09:34:41,813 org.nutz.resource.Scans.scan(Scans.java:274) DEBUG - Found 3 resource by src( custom/ ) , regex( ^.+[.]properties$ )
2017-09-27 09:34:41,814 org.nutz.ioc.impl.PropertiesProxy.setPaths(PropertiesProxy.java:113) DEBUG - load properties from File[E:\Work\InstelliJIDEAR_WorkSpaceNo.1\visualdisplay\target\classes\custom\cron.properties]
2017-09-27 09:34:41,819 org.nutz.ioc.impl.PropertiesProxy.setPaths(PropertiesProxy.java:113) DEBUG - load properties from File[E:\Work\InstelliJIDEAR_WorkSpaceNo.1\visualdisplay\target\classes\custom\db.properties]
2017-09-27 09:34:41,820 org.nutz.ioc.impl.PropertiesProxy.setPaths(PropertiesProxy.java:113) DEBUG - load properties from File[E:\Work\InstelliJIDEAR_WorkSpaceNo.1\visualdisplay\target\classes\custom\mail.properties]
2017-09-27 09:34:42,822 com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:715) INFO  - {dataSource-1} inited
2017-09-27 09:34:43,082 org.nutz.dao.jdbc.Jdbcs.<clinit>(Jdbcs.java:90) DEBUG - Jdbcs init complete
2017-09-27 09:34:43,082 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:103) INFO  - Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
Wed Sep 27 09:34:43 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2017-09-27 09:34:43,488 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:188) DEBUG - select expert : org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert
2017-09-27 09:34:43,488 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:199) DEBUG - JDBC Driver --> mysql-connector-java-5.1.40 ( Revision: 402933ef52cad9aa82624e80acbea46e3a701ce6 )
2017-09-27 09:34:43,488 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:200) DEBUG - JDBC Name   --> MySQL Connector Java
2017-09-27 09:34:43,488 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:202) DEBUG - JDBC URL    --> jdbc:mysql://127.0.0.1:3306/wcc
2017-09-27 09:34:43,639 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_client=utf8
2017-09-27 09:34:43,639 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_connection=utf8
2017-09-27 09:34:43,639 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_database=utf8
2017-09-27 09:34:43,639 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_filesystem=binary
2017-09-27 09:34:43,639 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_results=
2017-09-27 09:34:43,640 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_server=utf8
2017-09-27 09:34:43,640 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_set_system=utf8
2017-09-27 09:34:43,640 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:206) DEBUG - Mysql : character_sets_dir=C:\Program Files\MySQL\MySQL Server 5.7\share\charsets\
2017-09-27 09:34:43,643 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:213) DEBUG - Mysql : binlog_format=ROW
2017-09-27 09:34:43,644 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:220) DEBUG - Mysql : database=wcc
2017-09-27 09:34:43,645 org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.checkDataSource(MysqlJdbcExpert.java:226) DEBUG - Mysql : user=root@localhost
2017-09-27 09:34:43,668 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:221) DEBUG - Database info --> MYSQL:[MySQL - 5.7.17-log]
2017-09-27 09:34:43,684 org.nutz.resource.Scans.scan(Scans.java:274) DEBUG - Found 1 resource by src( sqls/ ) , regex( .(sql|sqlx|sqls)$ )
2017-09-27 09:34:43,684 org.nutz.dao.impl.FileSqlManager.refresh(FileSqlManager.java:52) DEBUG - load >> sql.sql from root=sqls/
2017-09-27 09:34:43,684 org.nutz.dao.impl.FileSqlManager.addSql(FileSqlManager.java:158) DEBUG - key=[WarningData.query2], sql=[SELECT count(*) FROM wcc_province_query]
2017-09-27 09:34:43,684 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) INFO  - skip not key sql line /*
2017-09-27 09:34:43,684 org.nutz.dao.impl.FileSqlManager.refresh(FileSqlManager.java:59) DEBUG - load 1 sql >> sql.sql from root=sqls/
2017-09-27 09:34:43,903 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - SELECT count(*) FROM wcc_province_query

java.lang.NullPointerException
	at org.nutz.dao.impl.sql.NutStatement.getInt(NutStatement.java:135)
	at Test2.test1(Test2.java:36)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Disconnected from the target VM, address: '127.0.0.1:58447', transport: 'socket'

Process finished with exit code -1

7 回复

没设置回调

import org.apache.log4j.Logger;
import org.junit.Test;
import org.nutz.dao.Dao;
import org.nutz.dao.SqlManager;
import org.nutz.dao.Sqls;
import org.nutz.dao.impl.FileSqlManager;
import org.nutz.dao.impl.NutDao;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.combo.ComboIocLoader;
import org.visual.tongyong.bean.WccProvinceQueryView;

import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;

public class Test2 {
    Logger log = Logger.getLogger(Test2.class);

    @Test
    public void test1() throws ClassNotFoundException {

        Ioc ioc = new NutIoc(new ComboIocLoader("*js", "ioc/",
                "*anno", "org.xisual.tongyong",
                "*tx",
                "*async"));

        DataSource ds = ioc.get(DataSource.class);
        Dao dao = new NutDao(ds);
        List<WccProvinceQueryView> list = new ArrayList<>();
        SqlManager sqlm = new FileSqlManager("sqls/");
        Sql sql = sqlm.create("WarningData.query2");
        Sql sql2= Sqls.create("SELECT count(*) FROM wcc_province_query");
        dao.execute(sql2);
        int i = sql2.getInt();
        log.info(list.size()+1);

    }
}

要设置回调啊

内置回调哪里有介绍???

大大的"回调的用处"都看不见???

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