ejb mysql_EJB+JPA,项目部署报错com.mysql.jdbc.exceptions.MySQLSyntaxErrorException。

错误:

Internal Exception: com.mysql.jdbc.exceptions.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 “”OPTION SQL_SELECT_LIMIT=DEFAULT”” at line 1

Error Code: 1064

Call: CREATE TABLE accountandpassword (id BIGINT NOT NULL, account VARCHAR(255), password VARCHAR(255), PRIMARY KEY (id))

Query: DataModifyQuery(sql=”CREATE TABLE accountandpassword (id BIGINT NOT NULL, account VARCHAR(255), password VARCHAR(255), PRIMARY KEY (id))”)

我用的是EJB3.0,已经实现了远程调用。

但是,EJB实现类中使用JPA方式对实体类进行管理。

数据库中没有表,据说可以在部署项目的时候会自动创建表。

实体bean:

package com.mycompany;

import java.io.Serializable;

import java.util.Objects;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

import javax.persistence.Table;

@Entity

@Table(name = "accountandpassword")

public class AccountAndPassword implements Serializable {

private static final long serialVersionUID = 1L;

@Id

@Column(table = "accountandpassword", name = "id", length = 20)

@GeneratedValue(strategy = GenerationType.AUTO)

private Long id;

@Column(table = "accountandpassword", name = "account", length = 255)

private String account;

@Column(table = "accountandpassword", name = "password", length = 255)

private String password;

public AccountAndPassword() {

}

public Long getId() {

return id;

}

public void setId(Long id) {

this.id = id;

}

public String getAccount() {

return account;

}

public void setAccount(String account) {

this.account = account;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

@Override

public int hashCode() {

int hash = 7;

hash = 83 * hash + Objects.hashCode(this.id);

hash = 83 * hash + Objects.hashCode(this.account);

hash = 83 * hash + Objects.hashCode(this.password);

return hash;

}

@Override

public boolean equals(Object obj) {

if (obj == null) {

return false;

}

if (getClass() != obj.getClass()) {

return false;

}

final AccountAndPassword other = (AccountAndPassword) obj;

if (!Objects.equals(this.id, other.id)) {

return false;

}

if (!Objects.equals(this.account, other.account)) {

return false;

}

return true;

}

@Override

public String toString() {

return "AccountAndPassword{" + "id=" + id + ", account=" + account + ", password=" + password + ""}"";

}

}

persistence .xml配置文件:

db-pool-01-JNDI

false

NONE

EJB接口实现类:

package com.mycompany;

import javax.ejb.Stateless;

import javax.persistence.EntityManager;

import javax.persistence.PersistenceContext;

@Stateless

public class MySession implements MySessionRemote{

@PersistenceContext(unitName = "Mypersistence")

EntityManager em;

@Override

public void setAccountAndPassword(String account, String password) {

AccountAndPassword aap = new AccountAndPassword();

aap.setAccount(account);

aap.setPassword(password);

em.persist(aap);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值