How to Retrive metadata from database of mysql
package My.com;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCDriverInformation
{
public static void main(String[] args) throws Exception
{
Connection con;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:","hr","hr");
System.out.println("Got Connection.");
DatabaseMetaData meta = con.getMetaData();
System.out.println("Driver Name : "+meta.getDriverName());
System.out.println("Driver Version : "+meta.getDriverVersion());
System.out.println("JdbcMajorVersion:"+meta.getJDBCMajorVersion());
System.out.println("URL="+meta.getURL().toString());
System.out.println("DataBaseproductName"+meta.getDatabaseProductName());
// System.out.println("Could not Get Connection");
}
}
Comments
Post a Comment