Java – JDBC create table

My web application is written in spring web MVC, which uses JDBC to process data I want my application to automatically create tables (and schemas) when the end user runs it for the first time (but load the created schema when it runs again) I am using HSQLDB as the database engine

What do you think and how do you do it? (I don't want to write special methods inside the app to check whether the tables exist. If they don't exist, create them. Is there a more useful method?)

PS: I am considering using hibernate instead of simple connection method Is there any way to solve it with Hibernate?

Solution

Simply create the database through the web application's installer This can also be done on a network basis

Another approach is to implement a servletcontextlistener, which checks the database and creates tables if necessary Servletcontextlistener executes only once during application startup, so you don't need to check it in every request

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>