ОК. Я не могу соединить мою JSP-программу с таблицей MYSQL для создания, получения или выполнения каких-либо действий с программой
Использование NetBeans 6.8, win XP sp 2, TOMCAT 6 и т. Д ...
В NetBeans показаны подключенные таблицы, уже примененный коннектор MYSQL в C:\apache-tomcat-5.5.33\apache-tomcat-5.5.33\common\lib\mysql-connector-java-5.1.18-bin.jar
Код, который я использую для подключения:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Creating Table in DB using JSP</h1>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<html>
<head>
<title>display data from the table using jsp</title>
</head>
<body>
<%
/* Create string of connection url within specified
format with machine name, port number
and database name. Here machine name id localhost
and database name is usermaster. */
String connectionURL = "jdbc:mysql://localhost:3306/ipsj";
// declare a connection by using Connection interface
Connection connection = null;
// declare object of Statement interface that is used for
// executing sql statements.
Statement statement = null;
try {
// Load JBBC driver "com.mysql.jdbc.Driver".
Class.forName("com.mysql.jdbc.Driver").newInstance();
/* Create a connection by using getConnection() method
that takes parameters of string type connection url, user
name and password to connect to database. */
connection = DriverManager.getConnection(connectionURL, "root", "");
/* createStatement() is used for create statement object
that is used for sending
sql statements to the specified database. */
statement = connection.createStatement();
// sql query to retrieve values from the secified table.
String QueryString = "create table user_master(id int not null auto_increment,name " + "varchar(25),city varchar(20), primary key(id));";
// execyteUpdate() mothod execute specified sql query.
statement.executeUpdate(QueryString);
out.print("QueryString");
%>
<TABLE>
<TR>
<TD align="center" >
<font size="+3" color="green">Congratulations !</font>
</TD>
</TR>
<tr>
<TD align="center" >
<font size="+2">Table of specified name is created successfully.</font>
</TD>
</tr>
<% } catch (Exception ex) {%>
</TABLE>
<TABLE>
<TR>
<TD align="center" >
<font size="+3" color="red">Some problems to create table.</font>
</TD>
</TR>
<%
}
%>
<tr>
<td align="center" >
<A HREF="welcome_to_database_query.jsp">
<font size="5" color="blue">back to home page</font>
</A>
</td>
</tr>
</TABLE>
</body>
Я не знаю, что не так, но он не может подключиться. Что я уже сделал:
- установленный сервер MYSQL,
- перезапустил TOMCAT,
- готово административные инструменты подключить вещь.