Tomcat+DBCP+SQLite

  • server.xml
			
								
			
  • WEB-INF/web.xml


	test	
	
		jdbc/sqlite
		javax.sql.DataSource
		Container
	

  • jsp
<%@ page language="java" contentType="text/html; charset=Shift_JIS" pageEncoding="Shift_JIS"%><%@ page import="java.sql.*,javax.naming.*,javax.sql.*,java.util.*,java.text.*,java.net.*" %>
<%
	InitialContext ic = new InitialContext();
	DataSource ds=(DataSource)ic.lookup("java:comp/env/jdbc/sqlite");
	Connection conn=ds.getConnection();
	PreparedStatement ps=conn.prepareStatement("select datetime('now','localtime')");
	ps.execute();
	ResultSet rs=ps.getResultSet();
	while(rs.next()){
		 out.println(rs.getString(1));
	}
 %>
  • 結果
2013-04-18 17:01:20