jsp新手,请教各位? - Java / Web 开发
程序如下:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>title</title>
</head>
<body>
<%
//驱动程序名
String driverName="com.mysql.jdbc.Driver";
//数据库用户名
String username="root";
//密码
String password="*******";
//数据库名
String dbName="study";
//表名
String tableName="product";
//连接字符串
String url="jdbc:mysql://localhost/"+dbName+"?characterEncoding=GBK";
try{
//加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//建立同数据库的连接对象
Connection connection=DriverManager.getConnection(url,username,password);
Statement statement = connection.createStatement();
String sql="SELECT * from "+tableName;
//发送要执行的SQL语句
ResultSet rs = statement.executeQuery(sql);
out.print("数据库连接成功<BR>");
while(rs.next())
{
out.print(rs.getint(1));
out.print(rs.getString("pdm"));
out.print(rs.getString("pname
相关问答:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 52 in the jsp file: /vip_info.jsp
ÕË cannot be resolved
49: <table border="1& ......
有谁用java做过打印发票的程序,感觉这方面不是很好控制,希望给点建议,最好能给出代码
简单点就调用window.print()
你也可以把下面代码放到你JSP中:
<html>
<head>
<title> ......
insert into [ScholarshipManagement].[dbo].[department] ([department],[specialization] ,[grade]) output inserted.departmentID values(? ,? ,? )
请问大哥们这个sql 语句应该用Java里的那个数据库操作方法? ......