Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving MYSQL Database structure information from Java

I'm trying to do with java and mysql the same I am used to with .net and SQL server:

By using Microsoft.SqlServer.Management.Smo I can access database structure information from my instance ( server name, table structure, columns, datatype, description, default value)

I tried to find to do the same with Java + MYSQL but it seems it is not so popular

any directions?

thanks

Ed

like image 708
RollRoll Avatar asked Apr 22 '26 18:04

RollRoll


1 Answers

The simplest way to accomplish it is by retrying the connection metadata, first you open a connection:

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db", "user","****");
DatabaseMetaData metaData = conn.getMetaData();

then start navigating through the metadata, you can check the available operations in DatabaseMedata

like image 88
Timoteo Ponce Avatar answered Apr 24 '26 06:04

Timoteo Ponce



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!