01: /*
02: * JdbcUtils.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.db;
13:
14: import java.sql.Connection;
15: import workbench.util.VersionNumber;
16:
17: /**
18: *
19: * @author support@sql-workbench.net
20: */
21: public class JdbcUtils {
22:
23: public static boolean hasMinimumServerVersion(WbConnection con,
24: String targetVersion) {
25: return hasMinimumServerVersion(con.getSqlConnection(),
26: targetVersion);
27: }
28:
29: public static boolean hasMinimumServerVersion(Connection con,
30: String targetVersion) {
31: VersionNumber target = new VersionNumber(targetVersion);
32: try {
33: int serverMajor = con.getMetaData()
34: .getDatabaseMajorVersion();
35: int serverMinor = con.getMetaData()
36: .getDatabaseMinorVersion();
37: VersionNumber server = new VersionNumber(serverMajor,
38: serverMinor);
39: return server.isNewerOrEqual(target);
40: } catch (Throwable th) {
41: return false;
42: }
43: }
44:
45: public static boolean hasMiniumDriverVersion(Connection con,
46: String targetVersion) {
47: VersionNumber target = new VersionNumber(targetVersion);
48: try {
49: int driverMajor = con.getMetaData().getDriverMajorVersion();
50: int driverMinor = con.getMetaData().getDriverMinorVersion();
51: VersionNumber driver = new VersionNumber(driverMajor,
52: driverMinor);
53: return driver.isNewerOrEqual(target);
54: } catch (Throwable th) {
55: return false;
56: }
57: }
58:
59: }
|