G
goddy
Unregistered / Unconfirmed
GUEST, unregistred user!
//<color>這邊有問題 Connection con = ds.getConnection("sa","");
</color>
<%@ page import = "java.util.*"%>
<%@ page import = "javax.naming.*"%>
<%@ page import = "javax.sql.*"%>
<%@ page import = "java.sql.*"%>
<HTML>
<HEAD>
<TITLE>
MoeDBCache Sample
</TITLE>
</HEAD>
<BODY>
<%
DataSource ds=null;
Context ctx=null;
java.util.Properties p = new java.util.Properties();
%>
<%-- Sybase implementation of InitialContextFactory --%>
<%
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sybase.ejb.InitialContextFactory");
%>
<%-- 伺服器的 IIOP port--%>
<%
p.put(Context.PROVIDER_URL, "IIOP://localhost:9000");
%>
<%-- Jaguar Server 的帳號和密碼--%>
<%
p.put(Context.SECURITY_PRINCIPAL, "jagadmin");
p.put(Context.SECURITY_CREDENTIALS, "");
%>
<%-- Create the initial context for Jaguar Server--%>
<%
try
{
ctx = new InitialContext(p);
//odbc名:sybase
ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/sybase");
}
catch(NamingException ne)
{
out.println("<p> Got The Exception, Please See The Jaguar Log </p><BR>");
ne.printStackTrace();
}
%>
<%-- Create the database Connection using 帳號/密碼 (sybase/odwasdbo) to login--%>
<%
try
{
//<color>這邊有問題 :Connection con = ds.getConnection("sa","");
</color>
Connection con = ds.getConnection("sa","");
Statement stmt = con.createStatement();
String SQLString="select ORG_NAME from TORG where ORG_NO='TEST000170'";
ResultSet rs=stmt.executeQuery(SQLString);
while (rs.next())
{
out.println("<p>查出機關名稱: "+rs.getString(1)+"</p>");
}
con.close();
out.println("<BR>");
out.println("<p> Process Completed </p>");
}
catch(SQLException sqe)
{
out.println("<p> Got The Exception, Please See The Jaguar Log </p><BR>");
sqe.printStackTrace();
}
%>
</BODY>
</HTML>
</color>
<%@ page import = "java.util.*"%>
<%@ page import = "javax.naming.*"%>
<%@ page import = "javax.sql.*"%>
<%@ page import = "java.sql.*"%>
<HTML>
<HEAD>
<TITLE>
MoeDBCache Sample
</TITLE>
</HEAD>
<BODY>
<%
DataSource ds=null;
Context ctx=null;
java.util.Properties p = new java.util.Properties();
%>
<%-- Sybase implementation of InitialContextFactory --%>
<%
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sybase.ejb.InitialContextFactory");
%>
<%-- 伺服器的 IIOP port--%>
<%
p.put(Context.PROVIDER_URL, "IIOP://localhost:9000");
%>
<%-- Jaguar Server 的帳號和密碼--%>
<%
p.put(Context.SECURITY_PRINCIPAL, "jagadmin");
p.put(Context.SECURITY_CREDENTIALS, "");
%>
<%-- Create the initial context for Jaguar Server--%>
<%
try
{
ctx = new InitialContext(p);
//odbc名:sybase
ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/sybase");
}
catch(NamingException ne)
{
out.println("<p> Got The Exception, Please See The Jaguar Log </p><BR>");
ne.printStackTrace();
}
%>
<%-- Create the database Connection using 帳號/密碼 (sybase/odwasdbo) to login--%>
<%
try
{
//<color>這邊有問題 :Connection con = ds.getConnection("sa","");
</color>
Connection con = ds.getConnection("sa","");
Statement stmt = con.createStatement();
String SQLString="select ORG_NAME from TORG where ORG_NO='TEST000170'";
ResultSet rs=stmt.executeQuery(SQLString);
while (rs.next())
{
out.println("<p>查出機關名稱: "+rs.getString(1)+"</p>");
}
con.close();
out.println("<BR>");
out.println("<p> Process Completed </p>");
}
catch(SQLException sqe)
{
out.println("<p> Got The Exception, Please See The Jaguar Log </p><BR>");
sqe.printStackTrace();
}
%>
</BODY>
</HTML>