mysql数据的批次转移
来源:互联网 发布:表提交给两个php 编辑:程序博客网 时间:2024/05/16 11:54
import java.sql.*;
public class Lib2 extends Thread{
private Connection con=null;
Connection conn=null;
private int Row=0;
public Lib2(){
try{
String driver="com.mysql.jdbc.Driver";
String sqlurl="jdbc:mysql://192.168.24.130:3306/spidera";
Class.forName(driver);
con=DriverManager.getConnection(sqlurl,"liuqianqian","qian");
}catch(Exception e){
}
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost/test","root","123");
System.out.println("链接数据库成功");
}catch(ClassNotFoundException e){
System.out.println("没有找到驱动");
e.printStackTrace();
}catch(SQLException e){
System.out.println("链接数据库失败");
e.printStackTrace();
}
}
public void run(){
while(true){
GetElements();
try {
Thread.sleep(12);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void GetElements(){
try{
String sql="select * from searchmess1 LIMIT "+Row+",200";
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(sql);
PreparedStatement pre=conn.prepareStatement("insert into mytest(id,url,time) values(?,?,?)");
while(rs.next()){
int ids=rs.getInt(1);
String url=rs.getString(2);
String title=rs.getString(3);
String date=rs.getString(4);
String source=rs.getString(5);
String readCount=rs.getString(6);
String text_xj1=rs.getString(7);
System.out.println(url);
pre.setInt(1, ids);
pre.setString(2,date);
pre.setString(3,url);
pre.addBatch();
}
pre.executeBatch();
rs.previous();
Row=Row+rs.getRow();
System.out.println(Row);
st.close();
}catch(Exception e){
System.out.println(e) ;}
}
public static void main(String[] agrs){
new Lib2().start();
}
}
0 0
- mysql数据的批次转移
- 转移 MySql 的数据目录
- DB2 与 MySQL 数据转移
- SQLite数据转移到Mysql
- MYSQL数据转移和“恢复”
- 关于mysql数据库韩文数据转移的问题
- 安装MYSQL之转移数据目录的成功经验
- MySQL同一数据库不同表数据的转移语句
- Spark Streaming: 保存上一个批次数据的计算结果
- 数据从 MySQL 转移到Oracle中
- MYSQL INNODB引擎转移数据方法
- mysql 创建表和转移数据
- 快速转移数据的方法
- 转移数据的存储过程
- 快速转移数据的方法
- 快速转移数据的方法
- ArcSDE数据转移的问题
- 关于批次的程序设计
- 2014多校联合-第六场
- 地址对齐
- spark上安装mysql与hive
- 人活着系列之平方数
- spring 工具
- mysql数据的批次转移
- POj 3511 Fermat’s Chirstmas Theorem
- HDU 4923 Room and Moor
- 开篇词
- 这一年,我在创业路上
- codeforces B. Pasha Maximizes
- ThreadingMixIn与HTTPServer
- POJ 2442 Sequence
- STL学习之LIST