MyEclipse------如何查询MySQL数据库里面表的信息
testExecuteQuary.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'testExecuteQuery.jsp' starting page</title>
</head> <body>
<%
//student为数据库的名字
String url="jdbc:mysql://localhost:3306/student?useSSL=true";
String useName="root";
String password="2277092";
String sql=null;
Connection conn=null;
Statement stmt=null; //加载驱动类
try{
Class.forName("com.mysql.jdbc.Driver");
out.print("加载驱动类成功");
}
catch(ClassNotFoundException e){
out.print("加载驱动类时出现异常");
} try{
conn=DriverManager.getConnection(url,useName,password); stmt=conn.createStatement();
sql="select * from info";//info为表名 ResultSet rs=stmt.executeQuery(sql);
%> <center>
<table border="1" width="270" cellspacing="0" cellpadding="0">
<tr>
<td width=50 align="center" valign="middle">学号</td>
<td width="80" align="center">姓名</td>
<td width=140 align="center">电话</td>
</tr> <%
while(rs.next()){
int id=rs.getInt(1);
String name=rs.getString(2);
String phone=rs.getString(3);
%> <tr>
<td height="40" align="center" valign="middle"><%=id %></td>
<td align="center" valign="middle"><%=name %></td>
<td align="center" valign="middle"><%=phone %></td>
</tr> <%
}
rs.close();
stmt.close();
%>
</table>
</center> <%
}
catch(SQLException e){
out.print("出现SQLException异常");
}
finally{
try{
if(conn!=null){
conn.close();
}
}
catch(SQLException e){
out.print("关闭数据库连接时出现异常");
}
}
%>
</body>
</html>
MyEclipse------如何查询MySQL数据库里面表的信息的更多相关文章
- MySQL中 如何查询表名中包含某字段的表 ,查询MySql数据库架构信息:数据库,表,表字段
--查询tablename 数据库中 以"_copy" 结尾的表 select table_name from information_schema.tables where ta ...
- 查询Mysql数据库所有数据库所占磁盘空间大小
查询Mysql数据库所有数据库所占磁盘空间大小: /,),' MB') as data_size, concat(truncate(sum(index_length)//,),'MB') as ind ...
- mybatis查询mysql数据库tinyint(1)变为boolean类型
mybatis查询mysql数据库对象转化为Map,tinyint(1)被转化为boolean类型,可以t通过避免使用tinyint(1)来解决.
- 【转】myeclipse中连接mysql数据库
1. 环境配置 下载地址: http://www.mysql.com/downloads/mysql/ 真麻烦,下载的话还需要注册和登录以及填个表.上面的信息还挺全的,乱填的信息也是可以接受的~~ ...
- linux 下C++查询mysql数据库
上一节我们看了怎么使用mysql提供的API来连接mysql数据库,现在来看看怎么执行一条简单的查询语句,并且把查询的结果显示出来. 准备工作:首先新建了一个数据库inote,在这个数据库下面新建了一 ...
- Mysql数据库里面的String类型依照数字来排序以及按时间排序的sql语句
今天做项目的时候,遇到个小小的问题,在数据库中查询的时候,要用String类型的ID进行一下排序!(注:ID字段为 varchar 类型) 解决的方法: 如: SELECT * FROM Stude ...
- ef查询mysql数据库数据支持DbFunctions函数
1.缘由 快下班的时候,一同事说在写linq查询语句时where条件中写两时间相减大于某具体天数报错:后来仔细一问,经抽象简化,可以总结为下面的公式: a.当前时间 减去 某表时间字段 大于 某具体天 ...
- linux定时查询mysql数据库并把结果保存到新表 然后备份数据库
脚本文件名:myshell内容如下: #!/bin/bash # mysql用户名 username="root" # mysql密码 password="root&qu ...
- spring boot使用jpa查询mysql数据库的视图时不报错,但查询结果数据总是重复第一条
问题描述: 在数据库里查询到的结果是正常显示的 在程序中返回的结果: 解决方法: 添加行号作为主键: 解决! 我明明是前端啊前端,为啥在搞后台....,总感觉我要在向全栈进发,希望自己有朝一日真的能成 ...
随机推荐
- WPF - MVVM - 如何将ComboBox的Selectchange事件binding到ViewModel
转:http://www.cnblogs.com/mantian/p/3713524.html 将所有的事件,属性,都映射到ViewModel中.好处多多,以后开发尽量用这种模式. 解决方法: 使用S ...
- Go Walk教程 - 流程控制( switch)
Go的 switch 非常灵活,表达式不必是常量或整数,执行的过程从上至下,直到找到匹配项,不要break: var score =98 var result string switch score/ ...
- C#定制并发送HTML邮件
HTML格式的邮件能够使用所有html/css使得邮件更丰富,比如现在很多newsletter 都是使用的html邮件. 今天试了一下,如何把图片嵌入到html中呢? 方法一,你的图片host到了in ...
- JS 禁用和重新启用a标签的点击事件
function changeHomePageModule(){ var css = $('#collapseExample').attr('class'); if(css=='collapse'){ ...
- 导航程序调试1---MFC应用以及数据显示程序
问题 error C2664: "BuildCommDCBW": 不能将参数 1 从"char *"转换为"LPCWSTR"经常出现这样的错 ...
- Web API 安全问题
目录 Web API 安全概览 安全隐患 1. 注入(Injection) 2. 无效认证和Session管理方式(Broken Authentication and Session Manageme ...
- Backbone源码分析-Backbone架构+流程图
作者:nuysoft/高云/nuysoft@gmail.com 声明:本文为原创文章,如需转载,请注明来源并保留原文链接. Backbone0.9.1源码分析分析系列 jQuery1.6.1源码分析系 ...
- 在matlab中对hsv进行均匀量化和非均匀量化
首先,进行非均匀量化,H,S,V三通道分别量化为16,4,4级,返回一个向量.量化依据如下表: function vec = getHsvHist(Image) [M,N,O] = size(Imag ...
- [CareerCup] 10.6 Find Duplicate URLs 找重复的URL链接
10.6 You have 10 billion URLs. How do you detect the duplicate documents? In this case, assume that ...
- LeetCode 笔记24 Palindrome Partitioning II (智商碾压)
Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...