使用JPA创建数据库? [英] Create database with JPA?

查看:500
本文介绍了使用JPA创建数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建(使用JPA-Java持久性api)持久性单元,然后创建持久性实体时,它们会自动在数据库中创建相应的表和字段.

When I create (using JPA - java persistence api) a persistence unit and then persistence entities they auto create the corresponding tables and fields in the database.

我还可以使其自动创建数据库(如果它不存在)吗?

我的对象是:

我的意思是,它会在数据库内部创建表和字段,但不会在数据库中创建,并且如果以前(手动)未创建数据库-一切都会失败.因此,在运行项目(如果需要,它将自动生成表和字段)之前,我首先必须创建(手动)数据库.

I mean it creates inside the database the tables and fields, but not the database, and if the database hasn't been created before (by hand) - everything fails. So before running the project (which will auto generate the tables and fields if needed) I first must create (by hand) a database.

我使用:Eclipse(Java,Hibernate,Flex/Air),MySQL

I use : Eclipse (Java, Hibernate, Flex/Air), MySQL

感谢所有信息

推荐答案

必须手动创建数据库(幸运的是,您没有问为什么;-).类似于用于连接数据库服务器的用户/密码组合,必须先存在用户/密码组合才能连接到数据库.

The database has to be created manually (Fortunatly you didn't ask why ;-). Which is similar to the user/password combination you use to connect to your database server, which must already exist in order to connect to the DB.

这篇关于使用JPA创建数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆