[英]How to work with .sql file in Java
I have collected a source code of a java project from internet where there is a file with .sql extension. 我已经从Internet收集了一个Java项目的源代码,其中有一个扩展名为.sql的文件。 I am new to java and don,t know how to work with and get access to .sql file. 我是Java的新手,不知道如何使用它并访问.sql文件。 How can I import the file in Netbeans and how to get access to that database. 如何在Netbeans中导入文件以及如何访问该数据库。 For your kind information, The project is on inventory management system and I have to get access to that database with a username and password contained inside it. 对于您的信息,该项目位于库存管理系统上,我必须使用包含在其中的用户名和密码来访问该数据库。 What will I do now? 我现在该怎么办? Do I have to install any additional software or something else? 我是否需要安装任何其他软件或其他工具? Please give a step by step procedure to do that. 请逐步进行操作。 Thanks in advance 提前致谢
Doing some simple google searches I found this: 做一些简单的谷歌搜索,我发现了这一点:
Running a .sql script using MySQL with JDBC 使用MySQL和JDBC运行.sql脚本
You could do it the way the OP did it, however its not as efficient as the answer. 您可以按照OP的方式进行操作,但是效率不如答案。 If you close the connection on how the OP did it in that post, and instead of writing the SQL, you can use a filereader to read from the SQL file and then use that data in the execute statement. 如果您在那篇文章中关闭了OP的连接方式,而不是编写SQL,则可以使用filereader读取SQL文件,然后在execute语句中使用该数据。
The only problem with his method though is that you need to install a JDBC driver. 但是,他的方法的唯一问题是您需要安装JDBC驱动程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.