简体   繁体   中英

Accessing data from MySQL

I need to import data from an excel file into MySQL and then access the data and display it. Can someone give me an idea as to how i should go about this? Also can someone brief me about the hardware/software requirements (MySQL version to be installed) for this task?

The question is quite broad. Here are a few hints:

  • Apache POI is a Java API for Microsoft Documents: with this you should be able to read your Excel file from Java

  • Then you can use JDBC to load your data to MySQL (assuming that you already have an appropriate database instance with table(s)). A quick search on the Web will give you many examples such as this .

I hope this helps!

http://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html

The above link explains how you can convert data from Excel and place it into a MySQL database.

http://dev.mysql.com/downloads/connector/j/

As for your next question, you will then need to get the JDBC connect for MySQL (link above) from the website, and use it to connect to your database.

Once that is done, there are various methods you can use to retrieve data, and return it for use in your program!

It depends on how your data is structured and how often you want this done.

For a one time load and if you have something easy (eg 1 table) you can use string concatenation functions in excel to create the inserts.

If you have a more complex thing you can use a programming language to create the inserts. I am on UNIX and I favor PERL, I am converting the excel spreadsheets into CSV files (save as) and parse these in PERL. If you are on Windows you might have better programming options.

Is this a testing/setup requirement or is it a business requirement that the application should be able to load data from excel files?

In first case I would simply convert it to CSV and import the data using mysqlimport or use a GUI tool like SQLYog. Software: SQLYog (Free Community Edition), mysqlimport (comes with MySQL)

In second case, I would use Apache POI. Software: Apache POI (Free and Open Source)

BTW it is also possible to create a ODBC data source using a excel file. You can use JDBC-ODBC bridge to access it.

Hardware: No special hardware requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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