简体   繁体   English

Java MySQL导出到可运行程序

[英]Java MySQL export to runnable program

I`m an Android developer, and recently started working on JAVA PC project for client. 我是一名Android开发人员,最近开始为客户端进行JAVA PC项目。

I wish to use MySQL database at my project but i`m little rusty at this. 我希望在我的项目中使用MySQL数据库,但对此我有点不满意。 Before I start learning and remembering how to connect SQL with Java, i would like to ask an important question. 在开始学习并记住如何将SQL与Java连接之前,我想问一个重要的问题。

After I export Executable JAR file for my client, the file will include MySQL connection? 为客户端导出可执行JAR文件后,该文件将包括MySQL连接吗? I mean will the client have to install MySQL on his PC and import the DB or something extra except java for running JAR file. 我的意思是,客户端将必须在其PC上安装MySQL并导入DB或Java以外的其他东西来运行JAR文件。

Depends where DB is running: 取决于数据库在哪里运行:

If it is an external server that is available over LAN/internet the client only needs the DB driver (search for mysql connector/J). 如果它是可通过LAN /互联网使用的外部服务器,则客户端仅需要DB驱动程序(搜索mysql connector / J)。

Otherwise, if the DB is to be run locally, the client needs to install mysql (and then still your program needs the Connector/J in classpath). 否则,如果数据库要在本地运行,则客户端需要安装mysql(然后您的程序仍需要classpath中的Connector / J)。 I don't think you can pack a mysql DB in a jar. 我认为您不能在一个jar中打包一个mysql DB。 But you probably can package a SQL script that fills the DB with some initial data. 但是您可能可以打包一个SQL脚本,用一些初始数据填充数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM