0

I have collected a source code of a java project from internet where there is a file with .sql extension. I am new to java and don,t know how to work with and get access to .sql file. How can I import the file in Netbeans and how to get access to that database. 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

  • If you're on linux or mac, `mysql schema_name < file.sql` in the terminal – yshavit Mar 29 '14 at 03:44
  • I am a windows user. @yshavit –  Mar 29 '14 at 03:47
  • which project did you "find from the internet"? You can read sql files with any text editor you like. If you want to execute them you'll need to know which database to use because there are many different sql dialects. – andih Mar 29 '14 at 04:05

2 Answers2

0

Doing some simple google searches I found this:

Running a .sql script using MySQL with JDBC

You could do it the way the OP did it, however its not as efficient as the answer. 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.

The only problem with his method though is that you need to install a JDBC driver.

Community
  • 1
  • 1
rshah
  • 675
  • 2
  • 12
  • 32
0
  1. install a kind of database(such as MySql)
  2. (optional) install a gui tool for your database(such as navicat)
  3. use the .sql files to create tables
  4. install a JDBC driver, which establishes a bridge between your Java code and database
  5. then you can access the database by using JDBC api
roll1987
  • 183
  • 1
  • 7
  • how to install a JDBC driver?? @roll1987 –  Mar 29 '14 at 03:52
  • Just search it on Google. Here is an [installation reference](http://dev.mysql.com/doc/connector-j/en/connector-j-installing.html) of a JDBC driver for MySQL . – roll1987 Mar 29 '14 at 04:00
  • Here is also an answer of a similar question. http://stackoverflow.com/questions/2907141/how-to-configure-mysql-jdbc-driver-mysql-connector-java-5-1-12 – roll1987 Mar 29 '14 at 04:06