001 /* 002 @license.text@ 003 */ 004 package biz.hammurapi.sql.cloudscape; 005 006 import java.io.IOException; 007 import java.io.InputStream; 008 import java.io.InputStreamReader; 009 import java.sql.SQLException; 010 011 import biz.hammurapi.sql.ConnectionPerThreadDataSource; 012 import biz.hammurapi.sql.SQLProcessor; 013 import biz.hammurapi.sql.Transaction; 014 015 016 /** 017 * Base class for HyperSonic data sources 018 * @author Pavel Vlasov 019 * @version $Revision: 1.2 $ 020 */ 021 public class CloudscapeDataSource extends ConnectionPerThreadDataSource { 022 023 024 /** 025 * @param driverClass 026 * @param dbURL 027 * @param user 028 * @param password 029 * @param initConnectionTransaction 030 * @throws ClassNotFoundException 031 */ 032 public CloudscapeDataSource( 033 String driverClass, 034 String dbURL, 035 String user, 036 String password, 037 Transaction initConnectionTransaction) throws ClassNotFoundException { 038 super(driverClass, dbURL, user, password, initConnectionTransaction); 039 } 040 041 /** 042 * @param scriptName Fully qualified name of a script to execute. E.g. org/hammurapi/results/persistent/jdbc/Hammurapi.Hypersonic.sql 043 * @throws SQLException 044 * @throws IOException 045 */ 046 public void initDB(String scriptName) throws SQLException, IOException { 047 if (scriptName!=null) { 048 InputStream in=getClass().getClassLoader().getResourceAsStream(scriptName); 049 if (in==null) { 050 throw new IOException("Can't load '"+scriptName+"'"); 051 } else { 052 new SQLProcessor(this, null).executeScript(new InputStreamReader(in)); 053 } 054 } 055 } 056 }