일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- WebLogic
- iBATIS
- PHP
- swingx
- Spring
- MySQL
- phonegap
- ibsheet
- MFC
- Android
- JDOM
- JSON
- node.js
- PLSQL
- sencha touch
- appspresso
- tomcat
- jsr 296
- 전자정부프레임워크
- Eclipse
- Ajax
- jQuery
- Google Map
- GPS
- 가우스
- dock
- 선택적조인
- rowspan
- Struts
- oracle
- Today
- Total
Where The Streets Have No Name
Using MySQL database with OC4J 본문
Configure OC4J
1. Install JDBC Diver
You have to copy the JDBC driver library i.e. mysql-connector-java-3.0.11-stable-bin.jar to %OC4J_HOME%/j2ee/home/applib directory.
2. Create DataSource
Create the datasource entry for connecting to the MySQL database in the %OC4J_HOME%/j2ee/home/config/data-sources.xml as follows:
<data-source
class="
com.mysql.jdbc.jdbc2.optional.MysqlDataSource" name="mysqlDS" location="jdbc/mysqlCoreDS" xa-location="jdbc/xa/mysqlXADS" ejb-location="jdbc/mysqlDS" connection-driver="com.mysql.jdbc.Driver" username="root" password="welcome" url="jdbc:mysql://
144.25.134.24/Test" inactivity-timeout="30" />
3. Test DataSource
You have to restart OC4J before you can use the DataSource you created in the previous step. Here is a sample JSP that you can use to test the DataSource that you created in the previous step.
<%@ page import="java.sql.*, javax.naming.*, javax.sql.*" %>
<% try { InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/mysqlDS");
Connection con = ds.getConnection(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("select * from emp"); %>
<h1> Test OC4J with MySQL DB </h1>
<table border=1 align=center>
<% while (rset.next()) { %>
<TR><TD>
<%= rset.getInt(1) %>
<TD>
<%= rset.getString(2) %>
<% } statement.close();
con.close(); }
catch(Exception e)
{ out.print(e.getMessage()); }
%>
한글처리관련 수정사항
<data-source
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
name="mysqlDS"
location="jdbc/mysqlCoreDS"
xa-location="jdbc/xa/mysqlXADS"
ejb-location="jdbc/mysqlDS"
connection-driver="org.git.mm.mysql.Driver"
username="root"
password=""
url="jdbc:mysql://localhost:5000/test?characterEncoding=euckr"
inactivity-timeout="30"
/>