Skip to content

Instantly share code, notes, and snippets.

@hu553in
Created March 11, 2025 14:11
Show Gist options
  • Save hu553in/525aa739892b7027e19b1d767fca5e3a to your computer and use it in GitHub Desktop.
Save hu553in/525aa739892b7027e19b1d767fca5e3a to your computer and use it in GitHub Desktop.
Print JDBC version
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