Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to import MySQL database in Java

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to import MySQL database in Java, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

What can Java be used for? Java is mainly used in: 1. Web development; 2. Android development; 3. Client development; 4. Web page development; 5. Enterprise application development; 6. Java big data development; 7. Game development and so on.

First create a new database named test

Next, execute the following Java code:

Import java.io.File;import java.io.IOException / * MySQL database import * * @ author GaoHuanjie * / public class MySQLDatabaseImport {/ * Java implementation MySQL database import * * @ author GaoHuanjie * @ param hostIP MySQL database server address IP * @ param userName database user name * @ param password password required to enter the database * @ param importFilePath database file path * @ param sqlFileName database file name * @ param databaseName database name to be imported * @ return returns true to indicate that the import is successful Otherwise, false is returned. * / public static boolean importDatabase (String hostIP, String userName, String password, String importFilePath, String sqlFileName, String databaseName) {File saveFile = new File (importFilePath); if (! saveFile.exists ()) {/ / if saveFile.mkdirs () does not exist in the directory / / create a folder} if (! importFilePath.endsWith (File.separator)) {importFilePath = importFilePath + File.separator;} StringBuilder stringBuilder=new StringBuilder (); stringBuilder.append ("mysql") .append ("- h") .append (hostIP) StringBuilder.append ("- u") .append (userName) .append ("- p") .append (password); stringBuilder.append ("") .append (databaseName); stringBuilder.append ("

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report