Created
March 11, 2025 14:11
-
-
Save hu553in/525aa739892b7027e19b1d767fca5e3a to your computer and use it in GitHub Desktop.
Print JDBC version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.hu553in.jdbc_version_checker | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.stereotype.Repository | |
import javax.sql.DataSource | |
@Repository | |
class JdbcVersionChecker { | |
@Autowired | |
private lateinit var dataSource: DataSource | |
fun printJdbcInfo() { | |
try { | |
dataSource.connection.use { conn -> | |
val metaData = conn?.metaData | |
// This prints the JDBC API version supported by the driver | |
println("JDBC Major Version: " + metaData?.jdbcMajorVersion) | |
println("JDBC Minor Version: " + metaData?.jdbcMinorVersion) | |
// This prints the driver version (which often includes the JDBC version details) | |
println("JDBC Driver Version: " + metaData?.driverVersion) | |
} | |
} catch (e: Exception) { | |
e.printStackTrace() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment