日期:2014-05-17  浏览次数:20623 次

java web菜鸟求教,弄了一个星期了,环境都没搭建好!求好人
环境是eclipse3.7加tomcat6.x,jdk是1.5,sql2000+sq4驱动,jdbc连接方式,有那三个包,
我在eclipse上写了一个类可以从sql中添加、删除数据都没有问题,当然运行的时候选的应用程序服务器!
现在我配置了三个文件:
第一个:context.xml
<?xml version="1.0" encoding="UTF-8"?> 

<Context antiJARLocking="true" path="/test" docBase="test" debug="5" reloadable="true" corssContext="true">
<Resource name="jdbc/ConnectionPool"  
auth="Container"  
  type="javax.sql.DataSource"  
  driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"  
  url="jdbc:microsoft:sqlserver://localhost:1433;DtatbaseName=db_net"  
  username="sa"  
  password="123"  
  maxActive="50"  
  maxIdle="20"  
  maxWait="10000" 
  factort ="org.apache.commous.dbcp.BasicDataSourceFactory"
  />  
</Context>
第二个web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>test</display-name>
  <resource-ref>
  <description>sql</description>
  <res-ref-name>jdbc/ConnectionPool</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
</web-app>
第三个test.jsp文件:
<%@ page contentType= "text/html; charset=UTF-8" language= "java" errorPage= " " %> 
<%@ page import= "java.sql.* "%> 
<%@ page import= "javax.sql.* "%> 
<%@ page import= "javax.naming.* "%> 
<html> 
<head> 
<meta http-equiv= "Content-Type " content= "text/html; charset=UTF-8"> 
<title> myfirst </title> 

</head> 
<body> 
<% 
DataSource ds = null; 
Connection conn = null; 
Statement stmt = null; 

try{ 
InitialContext ctx = new InitialContext(); 
ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/ConnectionPool"); 
conn = ds.getConnection(); 
  } 
  catch(Exception e)
  { 
  e.printStackTrace(); 
  } 
if(conn!=null)


 

  try{ 
  stmt=conn.createStatement();
  out.println(stmt);
  String tsql = "insert into test1(t) values('5')";
  out.println(tsql);
  stmt.executeUpdate(tsql);
}

  catch(Exception e)

  e.printStackTrace();
}
}
%> 

</body> 
</html> 


报错如下:
信息: Server startup in 478 ms
请问各位大侠,Java能够通过Apache的FTPClient删除FTP服务器上的文件夹吗