2 java111212121 jaVa111212121 于 2016.05.09 23:12 提问

Jfinal里面用C3P0这样连接数据库可以吗,为什么会报错呀

一直显示 这个附近有错误,单是我代码里面插了好多遍,没有 这个符号,
这个代码是按照Jfinal手册输入的,应该没错呀,为什么run in server后,也就是发布到tomcat7.0上会报这个错误呢?

package jfinal;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class jfinalConfig extends JFinalConfig {

@Override
public void configConstant(Constants me) {
    me.setDevMode(true);
}
@Override
public void configRoute(Routes me) {

    me.add("/Test", indexController.class);
}

@Override
public void configPlugin(Plugins me) {

    C3p0Plugin cp = new C3p0Plugin("jdbc:sqlserver://localhost:1433;DatabaseName=Mine;","sa","12345","com.microsoft.sqlserver.jdbc.SQLServerDriver");
    me.add(cp);
    ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
    me.add(arp);
    arp.addMapping("Test", Test.class);
}
@Override
public void configInterceptor(Interceptors me) {
}
@Override
public void configHandler(Handlers me) {
}

}


package jfinal;

import java.util.List;
import com.jfinal.core.Controller;

public class indexController extends Controller {
public void index(){
List list = Test.dao.find("select * from student");
renderJson(list);
}
}


package jfinal;

import com.jfinal.plugin.activerecord.Model;

public class Test extends Model {

public static final Test dao = new Test();

}

这是错误log,重复显示了好几遍

严重: Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin.
com.microsoft.sqlserver.jdbc.SQLServerException: '' 附近有语法错误。
com.jfinal.plugin.activerecord.ActiveRecordException: com.microsoft.sqlserver.jdbc.SQLServerException: '
' 附近有语法错误。
at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:54)
at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:225)
at com.jfinal.core.Config.startPlugins(Config.java:88)
at com.jfinal.core.Config.configJFinal(Config.java:49)
at com.jfinal.core.JFinal.init(JFinal.java:62)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
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.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4908)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5602)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

大家有什么好的办法吗

1个回答

k778899jx
k778899jx   2017.05.11 10:46

设置方言
arp.setDialect(new SqlServerDialect())

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!