How to get JDBC Driver Version in Java?

Below Java code shows, how to get JDBC Driver Version –

[java]
/****************************************************************************************
* Created on 05-2011 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.javasql;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
* Created by https://kodehelp.com
* Date: 5/1/11
*/
public class GetDriverVersion {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
final String driver = "oracle.jdbc.driver.OracleDriver";
final String url = "jdbc:oracle:thin:@HOST:PORT:SID";
final String USERNAME = "USERNAME";
final String PASSWORD = "PASSWORD";
Class.forName(driver); // load Oracle driver
Connection conn = DriverManager.getConnection(url, USERNAME, PASSWORD);
DatabaseMetaData meta = conn.getMetaData();
System.out.println(meta.getDriverVersion());
}
}
[/java]

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *