Commits

tbrugz committed 0b71b3d

logging: more connection info (for sqlrun too)

Comments (0)

Files changed (3)

src/tbrugz/sqldump/JDBCSchemaGrabber.java

 
 		feats = DBMSResources.instance().databaseSpecificFeaturesClass();
 		DatabaseMetaData dbmd = feats.getMetadataDecorator(conn.getMetaData());
-		showDBInfo(conn.getMetaData());
+		SQLUtils.ConnectionUtil.showDBInfo(conn.getMetaData());
 		
 		SchemaModel schemaModel = new SchemaModel();
 		String schemaPattern = papp.getProperty(SQLDump.PROP_DUMPSCHEMAPATTERN);
 		
 	}
 	
-	static void showDBInfo(DatabaseMetaData dbmd) {
-		try {
-			log.info("database info: "+dbmd.getDatabaseProductName()+"; "+dbmd.getDatabaseProductVersion()+" ["+dbmd.getDatabaseMajorVersion()+"."+dbmd.getDatabaseMinorVersion()+"]");
-			log.info("jdbc driver info: "+dbmd.getDriverName()+"; "+dbmd.getDriverVersion()+" ["+dbmd.getDriverMajorVersion()+"."+dbmd.getDriverMinorVersion()+"]");
-		} catch (Exception e) {
-			log.warn("error grabbing database/jdbc driver info: "+e);
-			//e.printStackTrace();
-		}
-	}
-	
 	//XXX shoud it be "grabTables"?
 	void grabRelations(SchemaModel schemaModel, DatabaseMetaData dbmd, DBMSFeatures dbmsfeatures, String schemaPattern, String tablePattern, boolean tableOnly) throws Exception { //, String padding
 		log.debug("grabRelations()... schema: "+schemaPattern+", tablePattern: "+tablePattern);

src/tbrugz/sqldump/SQLUtils.java

 import java.sql.Blob;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.Driver;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 
 			Class.forName(driverClass);
 			
+			Driver driver = DriverManager.getDriver(dbUrl);
+			if(driver!=null) {
+				log.debug("jdbc driver: "+driver+"; version: "+driver.getMajorVersion()+"."+driver.getMinorVersion()+"; jdbc-compliant: "+driver.jdbcCompliant());
+			}
+			else {
+				log.warn("jdbc driver not found [url: "+dbUrl+"]");
+			} 
+			
 			Properties p = new Properties();
 			p.setProperty(CONN_PROP_USER, papp.getProperty(propsPrefix+SUFFIX_USER, ""));
 			p.setProperty(CONN_PROP_PASSWORD, papp.getProperty(propsPrefix+SUFFIX_PASSWD, ""));
 			}
 			return conn;
 		}
+		
+		public static void showDBInfo(DatabaseMetaData dbmd) {
+			try {
+				log.info("database info: "+dbmd.getDatabaseProductName()+"; "+dbmd.getDatabaseProductVersion()+" ["+dbmd.getDatabaseMajorVersion()+"."+dbmd.getDatabaseMinorVersion()+"]");
+				log.info("jdbc driver info: "+dbmd.getDriverName()+"; "+dbmd.getDriverVersion()+" ["+dbmd.getDriverMajorVersion()+"."+dbmd.getDriverMinorVersion()+"]");
+				log.debug("jdbc version: "+dbmd.getJDBCMajorVersion()+"."+dbmd.getJDBCMinorVersion());
+			} catch (Exception e) {
+				log.warn("error grabbing database/jdbc driver info: "+e);
+				//e.printStackTrace();
+			}
+		}
 	}
 
 	static Log log = LogFactory.getLog(SQLUtils.class);

src_run/tbrugz/sqldump/sqlrun/SQLRun.java

 		
 		commitStrategty = getCommitStrategy( papp.getProperty(PROP_COMMIT_STATEGY) );
 		conn = SQLUtils.ConnectionUtil.initDBConnection(CONN_PROPS_PREFIX, papp, commitStrategty==CommitStrategy.AUTO_COMMIT);
+		SQLUtils.ConnectionUtil.showDBInfo(conn.getMetaData());
 	}
 	
 	public static List<String> getFiles(String dir, String fileRegex) {