jsp连接数据库问题 怎样对数据库查询,jsp语句,哪位兄弟能告知一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你说的是java连接数据库吧,查出对象传到jsp中显示出来。JDBC连接数据库的规范,package util;import java.sql.Connection;import java.sql.DriverManager;public class DBUtil { public static Connection getConnection() throws Exception{ Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test" + "?useUnicode=true&characterEncoding=utf8", "root","1234"); } catch (Exception e) { e.printStackTrace(); throw e; } return conn; } public static void close(Connection conn) throws Exception{ if(conn !=null){ try { conn.close(); } catch (Exception e) { e.printStackTrace(); throw e; } } } /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println(getConnection()); }} 不是,是按照条件查询的jsp语句 <%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url="jdbc:oracle:thin:@localhost:1521:orcl"; String user="scott"; String password="tiger"; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(); String sql="select * from Student where id < 1000"; ResultSet rs=stmt.executeQuery(sql); %>这样么? 你是说 根据jsp 里面的值 查询数据库 这个在单jsp页面是无法实现的 或者 将值传到action 中处理 include'conn.php';$name=$_GET['name'];$e_mail=$_GET['e_mail'];$tel=$_GET['phone'];$insert="insert into tbl_stu values(NULL,'$name','$e_mail','$tel')";; $sql="select *from tbl_stu"; $result=mysql_query($sql); $row=mysql_fetch_row($result); 直接在SQL WHERE子句里加啊 时间字段名>日期下限 and 时间字段名<日期上限 你说的是ajax吧,级联,不刷新整体页面,当你换了条件后,会改变下方列表数据吧。。 select * from tableName columnTime > MinTime and columnTime < MaxTime sql语句不会还是在jsp中查询不会神马模式 mvc还是ssh 我没有用什么模式,就是简单地练习一下jsp IP能访问含中文的资源文件, 用域名的就不行 在Java中怎么调用网上的WebService?? 返回ResultSet ,为什么为空? 不明白??? 请问web上的按钮能通过代码按下吗? servlet捕获jsp提交的表单值问题 用了两个小时终于将jive发布成功,但出现一些问题 请问如下代码如何用JSP表达 哪儿有java servlet development kit? <s:iterator>遍历list Java调固定Wsdl 代码 jquery easyui 碰到段代码不是很懂,请大神解释
package util;import java.sql.Connection;
import java.sql.DriverManager;public class DBUtil {
public static Connection getConnection() throws Exception{
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test" +
"?useUnicode=true&characterEncoding=utf8",
"root","1234");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
return conn;
}
public static void close(Connection conn) throws Exception{
if(conn !=null){
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
System.out.println(getConnection());
}}
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott"; String password="tiger"; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(); String sql="select * from Student where id < 1000"; ResultSet rs=stmt.executeQuery(sql);
%>这样么?
$name=$_GET['name'];
$e_mail=$_GET['e_mail'];
$tel=$_GET['phone'];
$insert="insert into tbl_stu values(NULL,'$name','$e_mail','$tel')";
; $sql="select *from tbl_stu";
$result=mysql_query($sql);
$row=mysql_fetch_row($result);
神马模式 mvc还是ssh