由xml保存数据库读取的数据
来源:互联网 发布:艾司唑仑片淘宝怎么搜 编辑:程序博客网 时间:2024/05/23 19:14
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.utils.FileUtil;
public class DBConn {
static String DBdriver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
static String url="jdbc:sqlserver://:1433; DatabaseName=count";
static String user="";
static String password="";
public static Connection getConnection(){
Connection conn=null;
try{
Class.forName(DBdriver);
conn=DriverManager.getConnection(url,user,password);
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
return conn;
}
public static void main(String[] args){
String content="";
int index=1;
Connection conn=null;
Statement st=null;
ResultSet rs=null;
try{
String sql="";
conn=getConnection();
st=conn.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
content="<mods ID=\""+index+">"+"\r\n"
+"<titleInfo>"+"\r\n"
+"<title></title>" +"\r\n"
+"<title></title>"+"\r\n"
+"<title></title>" +"\r\n"
+"</titleInfo>"+"\r\n"
+"<subjectList>"+"\r\n"
+"<subject></subject>"+"\r\n"
+"<subject></subject>"+"\r\n"
+"<topic></topic>" +"\r\n"
+"</subjectList>"+"\r\n"
+"<description>"+"</description>" +"\r\n"
+"<type></type>"+"\r\n"
+"<category></category>"
+"<identifier>"
+rs.getString("card")+","+rs.getString("state")+","+rs.getString("name")+","
+rs.getString("password")+","+rs.getInt("type")+","+rs.getString("idcard")+","
+rs.getDate("start_date")+","+rs.getDate("end_date")+","+rs.getDate("transact_date")+","
+rs.getInt("createlibrary")+","+rs.getInt("prefession_id")+rs.getInt("occupation_id")+","+rs.getInt("position_id")+","
+rs.getInt("degree_id")+","+rs.getInt("culture_id")+rs.getString("sex")+","+rs.getString("national")+","
+rs.getInt("age")+","+rs.getString("birth")+rs.getString("mobilephone")+","+rs.getString("telephone")+","
+rs.getString("unit")+","+rs.getString("address")+","+rs.getString("postcode")+","+rs.getString("origin")+","+rs.getString("memo")+","
+rs.getInt("money")+","+rs.getInt("saving")+","+rs.getString("other_id")
+"</identifier>"+"\r\n"
+"<coverage></coverage>" +"\r\n"
+"<date></date>"+"\r\n"
+"</mods>";
FileUtil.WriteTextToFile(content, "F:\\sqlxml\\"+index+".xml");
System.out.println("Index:"+index);
index++;
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
if(rs!=null)
rs.close();
rs=null;
}catch(Exception e1){
}
try{
if(st!=null)
st.close();
st=null;
}catch(Exception e1){
}
try{
if(conn!=null)
conn.close();
conn=null;
}catch(Exception e1){
}
}
}
}
- 由xml保存数据库读取的数据
- [drp 4] 使用dom4j,读取XML数据,保存至数据库
- 由数据库数据生成XML的方法(有源码)
- 由数据库数据生成XML的方法(有源码)
- 由数据库数据生成XML的方法(有源码)
- 读取excel数据并保存为xml
- C#读取XML文件数据和把数据保存至xml的方法
- Spark由浅到深(4) -- 数据读取与保存
- 保存xml数据到数据库的程序实现
- XML的数据提取和保存到数据库中
- 将数据库中表的数据保存到XML文件中
- 读取Excel数据,保存到数据库
- 读取XML的数据
- 简单的从数据库中读取数据自动生成XML
- 读取XML数据,在页面中展现、编辑、保存的实现
- 将matlab的数据保存xml 在c++下通过opencv读取;
- 数据库操作类与Xml文档操作(保存/读取Connectionstring)
- 数据库操作类与Xml文档操作(保存/读取Connectionstring)
- CMap在用CString做key类型时,ARG_KEY要选LPCTSTR
- ordfilt2函数 matlab
- Uva 10474 Where is the Marble?
- linux的时间操作
- JS中string 和 json对象的互转
- 由xml保存数据库读取的数据
- 事实对于创建网站,应该记住
- 深入浅出之正则表达式(二)
- 如何获取ResultSet的行数和列数
- 写给程序员
- 书商 - 您的书籍高清和360度的Flash动画
- 正则表达式使用
- [LeetCode] Same Tree
- Ext 中字段的排序