Jump to content

Jsp And Mysql Question


michail

Recommended Posts

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?

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...