提交表单后的javax.ejb.EJBException

时间:2014-08-09 18:40:45

标签: java java-ee exception

我创建了一个注册表单,该表单将向MySQL数据库注册一个新用户,但是当我提交表单时,我一直收到此Excepting。有什么可能是问题的线索?

实体类Korisnik.java:

@Entity
@Table(name = "korisnik", catalog = "cs230-projekat", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Korisnik.findAll", query = "SELECT k FROM Korisnik k"),
    @NamedQuery(name = "Korisnik.findByKorisnikId", query = "SELECT k FROM Korisnik k WHERE k.korisnikId = :korisnikId"),
    @NamedQuery(name = "Korisnik.findByIme", query = "SELECT k FROM Korisnik k WHERE k.ime = :ime"),
    @NamedQuery(name = "Korisnik.findByPrezime", query = "SELECT k FROM Korisnik k WHERE k.prezime = :prezime"),
    @NamedQuery(name = "Korisnik.findByUsernameAndPassword", query = "SELECT k FROM Korisnik k WHERE k.username = :username AND k.password = :password"),
    @NamedQuery(name = "Korisnik.findByUsername", query = "SELECT k FROM Korisnik k WHERE k.username = :username"),
    @NamedQuery(name = "Korisnik.findByPassword", query = "SELECT k FROM Korisnik k WHERE k.password = :password"),
    @NamedQuery(name = "Korisnik.findByEmail", query = "SELECT k FROM Korisnik k WHERE k.email = :email"),
    @NamedQuery(name = "Korisnik.findByLoggedin", query = "SELECT k FROM Korisnik k WHERE k.loggedin = :loggedin")})
public class Korisnik implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "KORISNIK_ID")
    private Integer korisnikId;
    @Size(max = 255)
    @Column(name = "IME")
    private String ime;
    @Size(max = 255)
    @Column(name = "PREZIME")
    private String prezime;
    @Size(max = 255)
    @Column(name = "USERNAME")
    private String username;
    @Size(max = 255)
    @Column(name = "PASSWORD")
    private String password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 255)
    @Column(name = "EMAIL")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "LOGGEDIN")
    private boolean loggedin;
    @OneToMany(mappedBy = "korisnikId")
    private Collection<Auto> autoCollection;
    @OneToMany(mappedBy = "korisnikId")
    private Collection<Komentari> komentariCollection;

托管bean KorisnikManagedBean.java:

@Named(value = "korisnikManagedBean")
@SessionScoped
public class KorisnikManagedBean implements Serializable {
    @EJB
    private KorisnikSessionBean korisnikSessionBean;
    private Korisnik newUser;
    private String username;
    private String password;
    private String email;
    private String ime;
    private String prezime;

    /**
     * Creates a new instance of KorisnikManagedBean
     */
    public KorisnikManagedBean() {
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getIme() {
        return ime;
    }

    public void setIme(String ime) {
        this.ime = ime;
    }

    public String getPrezime() {
        return prezime;
    }

    public void setPrezime(String prezime) {
        this.prezime = prezime;
    }

    public String register(){
        newUser = new Korisnik(getIme(), getPrezime(), getUsername(), getPassword(), getEmail());
        korisnikSessionBean.registration(newUser);
        return "index.xhtml";
    }

    public String login(){
        newUser = korisnikSessionBean.getKorisnik(getUsername(), getPassword());
        if(newUser == null){
            return "index.xhtml";
        } else {
            korisnikSessionBean.login(newUser);
            return "profile.xhtml";
        }
    }

    public String logout(){
        if(!newUser.getLoggedin()|| newUser == null){
            return "index.xhtml";
        } else {
            korisnikSessionBean.logout(newUser);
            return "index.xhtml";
        }
    }

}

会话Bean KorisnikSessionBean.java:

@Stateless
@LocalBean
public class KorisnikSessionBean {
    @PersistenceContext(unitName = "Projekat-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    public Korisnik registration(String username, String password, String email, String ime, String prezime){
        Korisnik korisnik = getKorisnik(username, password);
        if(korisnik == null){
            korisnik = new Korisnik(username, password, email, ime, prezime);
        persist(korisnik);
        return korisnik;
        }else{
            return null;
        }

    }
    public Korisnik registration(Korisnik k){
        Korisnik korisnik = getKorisnik(k.getUsername(), k.getPassword());
        if(korisnik == null){
            korisnik = new Korisnik(k.getIme(), k.getPrezime(), k.getUsername(), k.getPassword(), k.getEmail());
        persist(korisnik);
        return korisnik;
        }else{
            return null;
        }

    }
    public Korisnik getKorisnik(String username, String password){
        Korisnik korisnik;
        try{
            korisnik = em.createNamedQuery("Korisnik.findByUsernameAndPassword", Korisnik.class).setParameter("username", username).setParameter("password", password).getSingleResult();
         return korisnik;   
        }catch(NoResultException e){
            return null;
        }
    }
    public Korisnik login(Korisnik k){
        k.setLoggedin(true);
        em.merge(k);
        return null;
    }

    public Korisnik logout(Korisnik k){
        k.setLoggedin(false);
        em.merge(k);
        return null;
    }
    public List<Korisnik> getKorisnikList(){
        try{
            return em.createNamedQuery("User.findAll", Korisnik.class).getResultList();
        } catch(NoResultException e){
            System.out.println("No result list from getUserList");
            return null;
        }
    }
}

Registration.xhtml:

    <h:form>
                <div class="form-group">
                    <span class="form-control">Ime :</span>
                    <h:inputText class="form-control" value="#{korisnikManagedBean.ime}" validatorMessage="Molimo vas unesite vase ime">
                        <f:validateRegex pattern="^[a-zA-Z]{1,}$" />
                    </h:inputText>
                </div>
                <div class="form-group" style="margin-bottom: 13px;">
                    <span class="form-control">Prezime :</span>
                    <h:inputText class="form-control" value="#{korisnikManagedBean.prezime}" validatorMessage="Molimo vas unesite vase prezime">
                        <f:validateRegex pattern="^[a-zA-Z]{1,}$" />
                    </h:inputText>
                </div>
                <div class="form-group" style="margin-bottom: 13px;">
                    <span class="form-control">Username :</span>
                    <h:inputText class="form-control" value="#{korisnikManagedBean.username}" validatorMessage="Molimo vas unesite vas username">
                        <f:validateRegex pattern="^[a-zA-Z]{1,}$" />
                    </h:inputText>
                </div>
                <div class="form-group" style="margin-bottom: 13px;">
                    <span class="form-control">Password :</span>
                    <h:inputSecret class="form-control" value="#{korisnikManagedBean.password}" validatorMessage="Molimo vas unesite vas password">
                        <f:validateRegex pattern="^[a-zA-Z0-9]{1,}$" />
                    </h:inputSecret>
                </div>
                <div class="form-group" style="margin-bottom: 13px;">
                    <span class="form-control">Email :</span>
                    <h:inputText class="form-control" value="#{korisnikManagedBean.email}" validatorMessage="Molimo vas unesite vas e-mail">
                        <f:validateRegex pattern="^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$" />
                    </h:inputText>
                </div>
                <div class="submit">
                    <h:commandButton action="#{korisnikManagedBean.register()}" value="Register" class="btn btn-lg btn-success" />
                </div>
                <h:messages class="error" style="margin-left: 25px; margin-top: 10px;" />
</h:form>

提交上面的表格后,我得到了这个例外:

javax.faces.el.EvaluationException: javax.ejb.EJBException
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
    at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy364.registration(Unknown Source)
    at bean.__EJB31_Generated__KorisnikSessionBean__Intf____Bean__.registration(Unknown Source)
    at view.KorisnikManagedBean.register(KorisnikManagedBean.java:80)
    at view.KorisnikManagedBean$Proxy$_$$_WeldClientProxy.register(Unknown Source)
    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:483)
    at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
    at javax.el.BeanELResolver.invoke(BeanELResolver.java:536)
    at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    ... 35 more
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-projekat.korisnik WHERE ((USERNAME = 'asd') AND (PASSWORD = 'asd'))' at line 1
Error Code: 1064
Call: SELECT KORISNIK_ID, EMAIL, IME, LOGGEDIN, PASSWORD, PREZIME, USERNAME FROM cs230-projekat.korisnik WHERE ((USERNAME = ?) AND (PASSWORD = ?))
    bind => [2 parameters bound]
Query: ReadAllQuery(name="Korisnik.findByUsernameAndPassword" referenceClass=Korisnik sql="SELECT KORISNIK_ID, EMAIL, IME, LOGGEDIN, PASSWORD, PREZIME, USERNAME FROM cs230-projekat.korisnik WHERE ((USERNAME = ?) AND (PASSWORD = ?))")
    at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:377)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)
    at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:516)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:400)
    at bean.KorisnikSessionBean.getKorisnik(KorisnikSessionBean.java:56)
    at bean.KorisnikSessionBean.registration(KorisnikSessionBean.java:43)
    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:483)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
    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:483)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
    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:483)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    ... 53 more
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-projekat.korisnik WHERE ((USERNAME = 'asd') AND (PASSWORD = 'asd'))' at line 1
Error Code: 1064
Call: SELECT KORISNIK_ID, EMAIL, IME, LOGGEDIN, PASSWORD, PREZIME, USERNAME FROM cs230-projekat.korisnik WHERE ((USERNAME = ?) AND (PASSWORD = ?))
    bind => [2 parameters bound]
Query: ReadAllQuery(name="Korisnik.findByUsernameAndPassword" referenceClass=Korisnik sql="SELECT KORISNIK_ID, EMAIL, IME, LOGGEDIN, PASSWORD, PREZIME, USERNAME FROM cs230-projekat.korisnik WHERE ((USERNAME = ?) AND (PASSWORD = ?))")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:679)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1995)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2714)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2667)
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:477)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
    ... 87 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-projekat.korisnik WHERE ((USERNAME = 'asd') AND (PASSWORD = 'asd'))' at line 1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2310)
    at com.sun.gjc.spi.jdbc40.PreparedStatementWrapper40.executeQuery(PreparedStatementWrapper40.java:642)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1002)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:641)
    ... 107 more

1 个答案:

答案 0 :(得分:2)

问题是由catalog名称中的连字符引起的。您可以尝试添加反引号:

@Table(name = "korisnik", catalog = "`cs230-projekat`", schema = "")