我想知道R编程是否支持Firebird数据库?我检查了可能的链接,发现它支持Oracle,MySQL,PostgreSQL等,但没有找到Firebird.
// Original version of this file was part of InterClient 2.01 examples\n//\n// Copyright InterBase Software Corporation, 1998.\n// Written by com.inprise.interbase.interclient.r&d.PaulOstler :-)\n//\n// Code was modified by Roman Rokytskyy to show that Firebird JCA-JDBC driver\n// does not introduce additional complexity in normal driver usage scenario.\n//\n// An example of using a JDBC 2 Standard Extension DataSource.\n// The DataSource facility provides an alternative to the JDBC DriverManager,\n// essentially duplicating all of the driver manager\xe2\x80\x99s useful functionality.\n// Although, both mechanisms may be used by the same application if desired,\n// JavaSoft encourages developers to regard the DriverManager as a legacy\n// feature of the JDBC API.\n// Applications should use the DataSource API whenever possible.\n// A JDBC implementation that is accessed via the DataSource API is not\n// automatically registered with the DriverManager.\n// The DriverManager, Driver, and DriverPropertyInfo interfaces\n// may be deprecated in the future.\n\npublic final class DataSourceExample\n{\n static public void main (String args[]) throws Exception\n {\n // Create an Firebird data source manually;\n\n org.firebirdsql.pool.FBWrappingDataSource dataSource = \n new org.firebirdsql.pool.FBWrappingDataSource();\n\n // Set the standard properties\n dataSource.setDatabase ("localhost/3050:c:/database/test_charset.fdb");\n dataSource.setDescription ("An example database of employees");\n\n /*\n * Following properties were not deleted in order to show differences \n * between InterClient 2.01 data source implementation and Firebird one.\n */\n\n //dataSource.setDataSourceName ("Employee");\n //dataSource.setPortNumber (3060);\n //dataSource.setNetworkProtocol ("jdbc:interbase:");\n //dataSource.setRoleName (null);\n\n // Set the non-standard properties\n //dataSource.setCharSet (interbase.interclient.CharacterEncodings.NONE);\n //dataSource.setSuggestedCachePages (0);\n //dataSource.setSweepOnConnect (false);\n\n // this some kind of equivalent to dataSource.setNetworkProtocol(String)\n // possible values are "type4", "type2" and "embedded".\n dataSource.setType("TYPE4");\n\n // SQL Role can be set like this:\n // \n // dataSource.setRoleName("USER");\n\n // Character encoding for the connection is set to NONE\n dataSource.setEncoding("ISO8859_1");\n\n // other non-standard properties do not have setters\n // you can pass any DPB parameter\n //\n // dataSource.setNonStandardProperty("isc_dpb_sweep", null);\n // dataSource.setNonStandardProperty("isc_dpb_num_buffers", "75");\n\n // Connect to the Firebird DataSource\n try {\n dataSource.setLoginTimeout (10);\n java.sql.Connection c = dataSource.getConnection ("sysdba", "masterkey");\n\n java.sql.Statement stmt = c.createStatement();\n java.sql.ResultSet rs = stmt.executeQuery("SELECT * FROM test_charset");\n while(rs.next())\n System.out.println("a1 = " + rs.getString(1) + ", a2 = " + rs.getString(2));\n\n stmt.close();\n\n // At this point, there is no implicit driver instance\n // registered with the driver manager!\n System.out.println ("got connection");\n c.close ();\n }\n catch (java.sql.SQLException e) {\n e.printStackTrace();\n System.out.println ("sql exception: " + e.getMessage ());\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1102 次 |
| 最近记录: |