Pazartesi, Eylül 26, 2005

DB2 ve JSP

Geçen sen kasıp yapamadığımı bu sene hallettim. Oracle HTTP sunucusunu DB2'ya bağlanması için ayarlamam gerekiyordu. Şans mı bilmem. Neyse

/opt/oracle/product/9.2.0.2/Apache/Jserv/etc/jserv.properties

dosyasına şunu ekliyoruz

wrapper.classpath=/opt/oracle/product/9.2.0.2/jdbc/lib/db2java.zip
wrapper.classpath=/opt/oracle/product/9.2.0.2/jdbc/lib/db2jcc.jar

sonra apachectl graceful diyerek yeniden başlatıyoruz web sunucusunu.

Daha sonra aşağıdaki uyarıya göre db2jstrt komutuyla dinleyici çalıştırıyoruz.


The DB2 UDB JDBC Applet Server is started with the command: db2jstrt <port number>

When a port number is not provided, the default value of 6789 is used. Note that this is the port number you need to specify in the URL of the JDBC program, NOT the DB2 instance port number.

Every time the db2jstrt command is executed, a db2jd process is created.

DB2 için kullanacağımız bağlantı katarı şu şekilde test edilebilir


<%@page import="java.sql.*"%>

<% // Define the connection Connection con = null; // Check that the DB2Driver class is available System.getProperty("java.library.path"); Class.forName("COM.ibm.db2.jdbc.net.DB2Driver"); try { // DB2 veritabanına bağlanma denemesi DriverManager.registerDriver (new COM.ibm.db2.jdbc.net.DB2Driver()); out.println("Test başlıyor... "); con = DriverManager.getConnection("jdbc:db2://localhost:6789/user","user","passwd"); out.println("Test başarıyla tamamlandı. DB2'ya bağlanıldı. "); } // Hata oluşursa bilelim catch (SQLException e) { out.println(e.getMessage()); } %>

Hiç yorum yok: