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){
}
}
}
}