String sql = "SELECT COUNT(empno) FROM emp " +
" WHERE empno LIKE ? OR ename LIKE ? OR job LIKE ? OR TO_CHAR(hiredate,'yyyy-mm-dd') LIKE ? " +
" OR sal LIKE ? OR comm LIKE ? " ;
改为
String sql = "SELECT COUNT(empno) FROM emp " +
" WHERE empno LIKE ? OR ename LIKE ? OR job LIKE ? OR DATE_FORMAT(hiredate,'yyyy-mm-dd') LIKE ? " +
" OR sal LIKE ? OR comm LIKE ? " ;
2、mysql和oracle之间的转换:
sql = "SELECT * FROM (" +
" SELECT empno,ename,job,hiredate,sal,comm,ROWNUM rn " +
" FROM emp WHERE (empno LIKE ? OR ename LIKE ? OR job LIKE ? OR TO_CHAR(hiredate,'yyyy-mm-dd') LIKE ? OR sal LIKE ? OR comm LIKE ?) AND " +
" ROWNUM<=? ORDER BY empno) temp " +
" WHERE temp.rn>? " ;
改为:
sql = " SELECT * FROM emp WHERE empno LIKE ? OR ename LIKE ? OR job LIKE ? OR DATE_FORMAT(hiredate,'yyyy-mm-dd') LIKE ? "+
"OR sal LIKE ? OR comm LIKE ? ORDER BY empno LIMIT ? , ? ";
3、
改为
4、数据库的连接:
public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver" ;
public static final String DBURL = "jdbc:oracle:thin:@localhost:1521:MLDN" ;
public static final String DBUSER = "scott" ;
public static final String DBPASSWORD = "tiger" ;
改为:
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static final String DBUSER = "用户名";
public static final String DBPASSWORD = "t密码";
代码如下:
emp_list.jsp
<%@ page contentType="text/html" pageEncoding="GBK"%>
<%@ page import="java.sql.*" %>
www.mldnjava.cn,MLDN高端Java培训
<%!
public static final String URL = "emp_list.jsp" ;
%>
<%!
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static final String DBUSER = "root";
public static final String DBPASSWORD = "toor";
%>
<%
Connection conn = null ;
PreparedStatement pstmt = null ;
ResultSet rs = null ;
%>
<%
int currentPage = 1 ; // 为当前所在的页,默认在第1页
int lineSize = 3 ; // 每次显示的记录数
int allRecorders = 0 ; // 表示全部的记录数
String keyWord = request.getParameter("kw"); //接收查询关键字
%>
<%
try{
currentPage = Integer.parseInt(request.getParameter("cp")) ;
} catch(Exception e) {}
try{
lineSize = Integer.parseInt(request.getParameter("ls")) ;
} catch(Exception e) {}
if(keyWord == null){
keyWord = "";
}
%>
<%
Class.forName(DBDRIVER) ;
conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD) ;
String sql = "SELECT COUNT(empno) FROM emp " +
" WHERE empno LIKE ? OR ename LIKE ? OR job LIKE ? OR DATE_FORMAT(hiredate,'yyyy-mm-dd') LIKE ? " +
" OR sal LIKE ? OR comm LIKE ? " ;
pstmt = conn.prepareStatement(sql) ;
pstmt.setString(1,"%"+keyWord+"%") ;
pstmt.setString(2,"%"+keyWord+"%") ;
pstmt.setString(3,"%"+keyWord+"%") ;
pstmt.setString(4,"%"+keyWord+"%") ;
pstmt.setString(5,"%"+keyWord+"%") ;
pstmt.setString(6,"%"+keyWord+"%") ;
rs = pstmt.executeQuery() ;
if(rs.next()){ // 取得全部的记录数
allRecorders = rs.getInt(1) ;
}
%>
雇员列表
编号
姓名
职位
雇佣日期
工资
奖金
<%
sql = " SELECT * FROM emp WHERE empno LIKE ? OR ename LIKE ? OR job LIKE ? OR DATE_FORMAT(hiredate,'yyyy-mm-dd') LIKE ? "+
"OR sal LIKE ? OR comm LIKE ? ORDER BY empno LIMIT ? , ? ";
pstmt = conn.prepareStatement(sql) ;
pstmt.setString(1,"%"+keyWord+"%");
pstmt.setString(2,"%"+keyWord+"%");
pstmt.setString(3,"%"+keyWord+"%");
pstmt.setString(4,"%"+keyWord+"%");
pstmt.setString(5,"%"+keyWord+"%");
pstmt.setString(6,"%"+keyWord+"%");
pstmt.setInt(7,(currentPage -1)* lineSize) ;
pstmt.setInt(8,lineSize) ;
rs = pstmt.executeQuery() ;
%>
<%
while(rs.next()){
int empno = rs.getInt(1) ;
String ename = rs.getString(2) ;
String job = rs.getString(3) ;
Date hiredate = rs.getDate(4) ;
double sal = rs.getDouble(5) ;
double comm = rs.getDouble(6) ;
%>
1. aggregateByKey的运行机制
/**
* Aggregate the values of each key, using given combine functions and a neutral "zero value".
* This function can return a different result type
spark-sql是Spark bin目录下的一个可执行脚本,它的目的是通过这个脚本执行Hive的命令,即原来通过
hive>输入的指令可以通过spark-sql>输入的指令来完成。
spark-sql可以使用内置的Hive metadata-store,也可以使用已经独立安装的Hive的metadata store
关于Hive build into Spark
// Max value in Array
var arr = [1,2,3,5,3,2];Math.max.apply(null, arr); // 5
// Max value in Jaon Array
var arr = [{"x":"8/11/2009","y":0.026572007},{"x"
在使用XMlhttpRequest对象发送请求和响应之前,必须首先使用javaScript对象创建一个XMLHttpRquest对象。
var xmlhttp;
function getXMLHttpRequest(){
if(window.ActiveXObject){
xmlhttp:new ActiveXObject("Microsoft.XMLHTTP