Jump to content

Recommended Posts

Posted

I want to upload a war file and I have some questions that are not answered by wiki.

 

1)How to connect mysql and jsp on tommy server? I have done that locally but Im not sure how this works on tommy.

 

2)Does tommy support JNDI?

Posted

1)How to connect mysql and jsp on tommy server? I have done that locally but Im not sure how this works on tommy.

<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>JSP MySQL Test</title>
</head>
<body>

<sql:setDataSource var="mysql_test" driver="com.mysql.jdbc.Driver"

     url="jdbc:mysql://localhost/username_test?serverTimezone=UTC"
     user="username_test"  password="bestpasswordever"/>

<sql:query dataSource="${mysql_test}" var="result">
SELECT * from java;
</sql:query>

<c:forEach var="row" items="${result.rows}">
<c:out value="${row.data}"/>
</c:forEach>

</body>
</html>
Then download https://krydos.heliohost.org/jars/jstl-1.2.jar and https://krydos.heliohost.org/jars/mysql-connector-java-6.0.5.jar and put them in your WEB-INF/lib directory

 

Working example: https://krydos.heliohost.org/mysql.jsp

 

 

 

 

2)Does tommy support JNDI?

It doesn't look like anyone has tried that yet. Let us all know how it goes and the next person will know.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...