第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

無法從 persistence.xml 連接到 JDBC

無法從 persistence.xml 連接到 JDBC

大話西游666 2021-10-28 15:59:35
我有普通的 java 課本注釋為 jpa 的實(shí)體。我配置了持久性 xml,但我有很大的堆棧跟蹤,但我不明白。另外,我在 javax.persistence 中找不到 jdbc 包。關(guān)我什么事?這是我的實(shí)體package Java.JPA;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.Id;@Entitypublic class Book{  @Id @GeneratedValue  private long id;  private String title;  public Book()  {  }  public Book(String title) {    this.title = title;  }  public String getTitle()  {    return title;  }  public void setTitle(String title) {    this.title = title;  }}這是我的主要課程package Java;import Java.JPA.Book;import java.sql.SQLException;import javax.persistence.EntityManager;import javax.persistence.EntityManagerFactory;import javax.persistence.EntityTransaction;import javax.persistence.Persistence;public class main{  public static void main(String[] args) throws SQLException, ClassNotFoundException {    EntityManagerFactory emf = Persistence.createEntityManagerFactory("example");    EntityManager em = emf.createEntityManager();    Book book = new Book("TestJPA");    EntityTransaction tx = em.getTransaction();    tx.begin();    em.persist(book);    tx.commit();    em.close();    emf.close();  }}這是我的persistence.xml<?xml version="1.0" encoding="UTF-8" ?><persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence                                 http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"  version="2.1">  <persistence-unit name="example">    <!--<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>-->    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 134 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號