Resin的文件夹下有个conf文件夹,你用EditPlus打开其中的配置文件resin.conf,建议你在修改前备份一下。然后修改里面的配置文件就应该可以了。
解决方案 »
- 请教大虾:JSF web 应用 上写Junit
- BOM 与 DOM
- 两个SSH布署到同一个tomcat6.0下有一个不能启动的问题
- <转www.puttop.com>jQuery调用JSON时,JSONException: There is a cycle in the hierarchy!
- 如何将页面产生的文件,直接生成在客户端,而不是服务器端?
- 论坛发帖页面那种能既能上传文件又能提交表单的界面是怎么实现的
- xiaohuozhi() 和pigo() 两位网友请进
- 哪位高手指点下Struts怎么实现动态下拉菜单~~~
- 一个小问题,大家帮帮忙
- Hibernate中@ManyToOne与@OneToMany注解查询结果用gson序列化出现循环引用问题
- torque是做什么的?怎么用?
- 请问有无工具将数据从EXCEL直接导入至数据库中?
我也知道resin.conf,但是要怎么改啊?
<res-ref-name>jdbc/DBConn</res-ref-name>
<!--连接名称-->
<res-type>javax.sql.DataSource</res-type>
<init-param driver-name="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<init-param url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DataBaseName=master"/>
<!--SQLSERVER连接方式,以及数据库名称-->
<init-param user="sa"/>
<!--SQLSERVER连接用户名-->
<init-param password=""/>
<!--SQLSERVER连接口令-->
<init-param max-connections="20"/>
<init-param max-idle-time="20"/>
<init-param max-active-time="3"/>
<init-param max-pool-time="24"/>
<init-param connection-wait-time="5"/>
<log id='/caucho.com/sql/pool' href='logs/dbpool.log' timestamp='[%H:%M:%S.%s]'/>
<!--其他连接设置,具体参考resin的文档了-->
</resource-ref>
<database>
<jndi-name>jdbc/MSSql</jndi-name>
<driver type="com.microsoft.jdbc.sqlserver.SQLServerDriver">
<url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=DBTest</url>
<user>sa</user>
<password></password> </driver>
<prepared-statement-cache-size>8</prepared-statement-cache-size>
<max-connections>20</max-connections>
<max-idle-time>30s</max-idle-time>
</database>
500 Servlet Exception
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]第
1 行: ' ' 附近有语法错误。
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)
at _jsp._msserver__jsp._jspService(msserver.jsp:12)
at com.caucho.jsp.JavaPage.service(JavaPage.java:61)
at com.caucho.jsp.Page.pageservice(Page.java:569)
at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:149)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:386)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:332)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:457)
at com.caucho.util.ThreadPool.run(ThreadPool.java:398)
at java.lang.Thread.run(Thread.java:595)
--------------------------------------------------------------------------------
Resin-3.0.10 (built Mon, 20 Dec 2004 01:12:17 PST) ***
我测试用的jsp代码:<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.io.*,java.sql.*,java.util.*"%>
<html>
<body>
<% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://lookio:1433;DatabaseName=pubs";
String user="sa";
String password = "";
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select job_id,job_desc from jobs";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){%>
您的第一个字段内容为:<%=rs.getString(1)%><br>
您的第二个字段内容为:<%=rs.getString(2)%><br>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<% rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
****还有,“<resource-ref>”这个标签是什么作用?具体位置加在哪里?和 yuanjiasheng(软虫)那样的写法有什么不同?
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.io.*" import="java.sql.*" import="javax.naming.*" import="javax.sql.DataSource" %><html>
<head>
<title>
pool
</title>
</head>
<body bgcolor="#ffffff">
<% javax.sql.DataSource ds = null;
Connection myConn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Context ctx = new InitialContext();
// get jndi name
ds = (javax.sql.DataSource) ctx.lookup("MSSQL");
}
catch (Exception e) {
out.println(e.toString());
}
try {
out.println("开始连接:"); myConn = ds.getConnection();
out.println("连接成功!"); stmt = myConn.createStatement();
out.println("创建语句成功!"); rs = stmt.executeQuery("select job_desc from jobs");
while (rs.next()) {
out.println(rs.getString("job_desc"));
}
rs.close();
stmt.close();
}
catch (Exception e) {
out.println(e.toString());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (Exception ei) {
out.println(ei.toString());
}
}
if (stmt != null) {
try {
stmt.close();
}
catch (Exception ex) {
out.println(ex.toString());
}
}
if (myConn != null) {
try {
myConn.close();
}
catch (Exception ee) {}
}
}
%>
</body>
</html>**********resin.conf里我把下面这段加到被注释掉的<database>标签后面了: <database>
<jndi-name>jdbc/MSSQL</jndi-name>
<driver type="com.microsoft.jdbc.sqlserver.SQLServerDriver">
<url>jdbc:microsoft:sqlserver://192.168.0.123:1433;DatabaseName=pubs</url>
<user>sa</user>
<password/>
</driver>
<prepared-statement-cache-size>8</prepared-statement-cache-size>
<max-connections>20</max-connections>
<max-idle-time>30s</max-idle-time>
</database>
************运行的结果:“开始连接: java.lang.NullPointerException ”相同的路径,执行其他不连接数据库的JSP文件正常。这到底是怎么回事?
<jndi-name>jdbc/MSSQL</jndi-name>//这里改一下
ds = (javax.sql.DataSource) ctx.lookup("MSSQL");ds = (javax.sql.DataSource) ctx.lookup("jdbc/MSSQL");