![]() |
|
||||||||||||||
| | 网站首页 | 数据库教程 | web编程 | 服务器 | 程序设计 | | ||
|
||
|
|||||||||||||||||||||||
| 在PB7中,通过JDBC,JDS或JDM接口与 数据库 互连 | |||||||||||||||||||||||
作者:佚名 文章来源:不详 点击数: 更新时间:2007-7-3 ![]() |
|||||||||||||||||||||||
|
Connecting to a database via the JDBC JDS or JDM interface through PowerBuilder 7
Document:Summary This document contains information on how to prepare and define the JDBC JDS and JDM interfaces that are shipped with PowerBuilder 7. This document is a supplement to the connection information found in the PowerBuilder Connecting to Your Database manual. It goes into more detail in regard how to connect to the new JDBC JDS and JDM interfaces and supplies up to date information. What is the JDBC API? Java Database Connectivity (JDBC) is a standard Java API (application programming interface) for database-independent connectivity between Java applications and a wide range of databases. It consists of a set of classes and interfaces written in Java. It can establish a connection with a database, send SQL statements and process the results. It is defined by JavaSoft (http://java.sun.com/products/jdbc). The JDBC API defines Java classes to represent database connections, SQL statements, result sets, database metadata, etc. It allows a programmer writing in the Java programming language to issue SQL statements and process the results. JDBC is the primary API for database access in the Java programming language. The JDBC API is implemented via a driver manager that can support multiple drivers connecting to different databases. The JDBC classes are included in Java 1.1 as the java.sql package. Why use the JDBC Interfaces? Depending on which product you are using, the use of the JDBC interface enables you to develop several types of components and/or applications in PowerBuilder:
What are the JDBC JDS and JDM interfaces? The third-party JDBC driver is 100% Java byte code and it requires a Java Virtual Machine (VM) to run the code. The two most popular VMs support different APIs to invoke Java methods. These are Sun VM JDK (or Java Runtime Environment JRE 1.1.7) and Microsoft VM (Microsoft SDK for Java version 3.1). Therefore, we have provided two versions of JDBC interfaces, JDS for Sun VM and JDM for Microsoft VM. Both interfaces provide connectivity to databases that comply with the JDBC API. The PowerBuilder JDBC interface includes the following:
Preparing to use the JDBC interfaces Depending upon how you are developing your applications and which vendor you are using, you must follow these steps in order to connect to JDBC JDM or JDBC JDS:
Configure the database server for its JDBC connection and install its JDBC-compliant driver and network software. You must obtain the database server software from your vendor. For configuration instructions, see your database vendor's documentation. You must obtain the appropriate JDBC-compliant driver software from your vendor. PowerBuilder supports any JDBC-compliant third party driver including Oracle JDBC driver version 8.03 or higher and Sybase jConnect version 4.0. jConnect can be installed from the EAStudio setup when the Adaptive Server Anywhere database is selected. To use the jConnect driver: In order to use jConnect as a JDBC-compliant driver, you need to execute the proper JDBC stored procedures on the Adaptive Server databases. For more information on this, consult the jConnect documentation. To use Oracle JDBC driver: Please consult Oracle's documentation. For installation and instructions for your network software, see your network administrator. Verify that Java VM is installed on your machine The following VMs are available free of charge from their respective vendors: ?For Microsoft VM: Microsoft VM that supports Microsoft SDK for Java 3.1 should be installed. http://www.microsoft.com/java/download.htm A file msjava.dll should be installed to WinNT\system32 directory in Windows NT and it should be in Windows\System in Windows 95.
?For Sun Java Runtime Environment (JRE) version 1.1.7: http://java.sun.com/products Install the JDBC interface (From this point on, this description assumes that default locations were used during the install). Only PowerBuilder Enterprise includes the JDM and JDS interfaces. To install the JDM and JDS interfaces, choose the Custom installation option and select the JDM and JDS interfaces. The PBJDM70.DLL and PBJDS70.DLL will be installed into \Program Files\Sybase\Shared. The PB.INI should contain entries for JDM and JDS if these were selected for installation. Set the PATH and CLASSPATH environment variables For Windows 95 and Windows 98: Open autoexec.bat file and add or change the PATH and CLASSPATH statements as follows: 1. Start the system editor. Choose "Start", "Run" and enter sysedit, then click OK. The system editor starts up with displaying AUTOEXEC.BAT. 2. Look for the PATH and CLASSPATH statements. You may need to add CLASSPATH. Add the appropriate entries described below. For Windows NT: Change the PATH and CLASSPATH variables as follows: 1. Go to Control Panel, Select System, and Select Environment Tab.
For Oracle Thin Driver:
Define a Database Profile from PowerBuilder: To define a profile, the minimum parameters required under the Connection Tab are Profile Name, Driver Name, URL, Login ID and Password. ?Driver Name: should be provided by your JDBC driver's vendor. For example, ? URL: Usually jdbc, followed by :vendor, followed by :driver-type or protocol, followed by : or @server name or IP address, followed by / or :database. For example,
jdbc:oracle:thin:@ora8nt:1521:oracl
user=dba;password=sql;SQLINITSTRING=set textsize 50000; Database Connectivity Examples:
1. Run dbisql.exe from \Program Files\Sybase\Adaptive Server Anywhere 6.0\win32.
Prior to connecting to ASA via the PowerBuilder Database Profile, you must start up the database engine by running Interactive SQL.
Example Database Profile parameters:
? Adaptive Server Enterprise or Sybase SQLServer:
You need to run the stored procedures sql_server.sql located in \Program Files\Sybase\Adaptive Server Anywhere 6.0\jconnect\sp once before you connect to Adaptive Server Enterprise from PowerBuilder. Example Database Profile parameters: (where database is tsdata, userid is tslogin2 and password is tspass2) Driver: com.sybase.jdbc.SybDriver Example Database Profile parameters: (where Database Server (machine name) is ora80nt) Driver: oracle.jdbc.driver.OracleDriverCommon Error Messages "JavaException: "PowerBuilder "PowerBuilder "PowerBuilder "PowerBuilder "PowerBuilder Frequently Asked Questions
The JDBC Driver Manager Trace logs errors and informational messages originating from the Driver object currently loaded (such as Sybase's jConnect JDBC driver) when PowerBuilder connects to a database via the JDBC interface. It writes this information to a default log file named JDBC.LOG or to a log file that you specify. The amount of trace output varies depending on the JDBC driver being used. The JDBC Driver Manager Trace tool cannot trace connections through one of the native database interfaces.
|
|||||||||||||||||||||||
| 文章录入:admin 责任编辑:admin | |||||||||||||||||||||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | |||||||||||||||||||||||
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 网站地图 | 管理登录 | | |||
|