ibserver와 interserver가 실행되고 있어야 하고,
jdk가 설치되어 있어야 합니다.
interclient.jar CLASSPATH 등록도 필요합니다.
http://www.ibphoenix.com/ibp_interclient.html
// Copyright InterBase Software Corporation, 1998.
// Written by com.inprise.interbase.interclient.r&d.PaulOstler :-)
//
// An example of using a JDBC 2 Standard Extension DataSource.
// The DataSource facility provides an alternative to the JDBC DriverManager,
// essentially duplicating all of the driver manager’s useful functionality.
// Although, both mechanisms may be used by the same application if desired,
// JavaSoft encourages developers to regard the DriverManager as a legacy
// feature of the JDBC API.
// Applications should use the DataSource API whenever possible.
// A JDBC implementation that is accessed via the DataSource API is not
// automatically registered with the DriverManager.
// The DriverManager, Driver, and DriverPropertyInfo interfaces
// may be deprecated in the future.
public final class DataSourceExample
{
static public void main (String args[])
{
// Create an InterClient data source bean manually;
// beans are normally manipulated by a GUI tool.
// Bean properties are always set using the setXXX signature.
interbase.interclient.DataSource dataSource = new interbase.interclient.DataSource ();
// Set the standard properties
dataSource.setServerName ("perdy");
dataSource.setDatabaseName ("d:/databases/employee.gdb");
dataSource.setDataSourceName ("Employee");
dataSource.setDescription ("An example database of employees");
dataSource.setPortNumber (3060);
dataSource.setNetworkProtocol ("jdbc:interbase:");
dataSource.setRoleName (null);
// Set the non-standard properties
dataSource.setCharSet (interbase.interclient.CharacterEncodings.NONE);
dataSource.setSuggestedCachePages (0);
dataSource.setSweepOnConnect (false);
// Connect to the InterClient DataSource
try {
dataSource.setLoginTimeout (10);
java.sql.Connection c = dataSource.getConnection ("sysdba", "masterkey");
// At this point, there is no implicit driver instance
// registered with the driver manager!
System.out.println ("got connection");
c.close ();
}
catch (java.sql.SQLException e) {
System.out.println ("sql exception: " + e.getMessage ());
}
}
}
허재혁 님이 쓰신 글 :
: 이번것은 좀 짧은 소스네요...
: 역시 컴파일은 되는데, 실행이 되질 않네요...부탁드립니다.
: 좀 살펴보니까.. InterBase에서는 자체의 자바라이브러리에 의해서 DB연결을 하는 것 같군요.
: Connection, Statement, ResultSet.....
:
: <예제 및 에러 메세지>
: import interbase.interclient.*;
: import java.util.*;
:
: public class Conecta {
: public static void main(String[] args) {
: try {
: String dbUrl = "jdbc:interbase://196.1.8.90/f:/EasyDemo.gdb";
: String user = "SYSDBA";
: String password = "asinforuser";
: Properties props = new Properties();
: // Load the driver (registers itself)
: Class.forName("interbase.interclient.Driver");
: props.setProperty("USERNAME", user);
: props.setProperty("PASSWORD", password);
: java.sql.Connection c = java.sql.DriverManager.getConnection(dbUrl, props);
: } catch (Exception e) {
: System.out.println(e);
: }
: }
: } ///:~
: /*
: And the error message is:
:
: C:\WINDOWS\TEMP\Pruebas Interbase>java Conecta
: Exception in thread "main" java.lang.VerifyError: (class: interbase/interclient/
: ErrorKey, method: _$372 signature: (Ljava/lang/String;Ljava/lang/String;I)V) Exp
: ecting to find unitialized object on stack
: at interbase.interclient.Driver.connect(Driver.java:180)
: at java.sql.DriverManager.getConnection(Unknown Source)
: at java.sql.DriverManager.getConnection(Unknown Source)
: at Conecta.main(Conecta.java:16)
:
: Thanks.
: Beni.
: */