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
相关问答:
我在 java核心技术上 看了一个 利用 Java socket email的例子 可是怎么也 不成功 为什么?
源码
Java code:
package cn.com.test.email;
import java.awt.GridBagLayout;
import java.awt.event.Action ......
题目:
有1,2,3,4,5,6六个数字排序,用java程序计算出排序的种类。
要求:一,以4开头
二,2,3不能相邻
三,不能以5开头
希望大家能即 ......
有谁用java做过打印发票的程序,感觉这方面不是很好控制,希望给点建议,最好能给出代码
简单点就调用window.print()
你也可以把下面代码放到你JSP中:
<html>
<head>
<title> ......
我是个新手,望高手解答
我现在已经安装了mysql,也有mysql的jdbc。但我怎么配置后,才能在MyEclipse里操作mysql呢?请高手说详细点
打开Myeclipse----window---open perspective---MyEclipse database explorer-- ......
使用java在windows7 32位下连接MSSQL。
两台机器,windows7 32位,在控制面板里面全部设置语言和区域选项都english-unitedstates
唯一区别只有在安装SQL server 2008的时候 选择的字符集不一样,
exec sp_helpsor ......