求助如题~。
准备用Eclipse开发工具,各位有没有什么思路或者代码提供借鉴的。谢谢!
准备用Eclipse开发工具,各位有没有什么思路或者代码提供借鉴的。谢谢!
解决方案 »
- 对插入数据库的值进行加密
- C++中有没有一种可以存储大量int类型数据的数据结构?
- hibernate使用load加载
- struts问题,怎么从后台得到<bean:write name="aa">的值
- 关于window.parent 镶嵌到上下结构框里丢失问题
- dom4j 解析xml 忽略 dtd 解决生成 Document 还是很慢 的问题
- 如何每一天创建一个新的文件夹用于上传文件
- 一个关于FAT32目录下存放多少文件的问题
- J2EE的开发经验
- JAVA高手救命,如何对JSP程序进行错误控制!
- 怎么让系统每天自动计费,紧急~
- 请问如何用JavaScript实现点一个图片然后这个图片变成另一个图片?
insert a(id,name) values(1,"dreamover");
commit;execute the sql script
import java.sql.*;
import java.io.*;public class OutData
{
public static int outputFile() throws IOException,SQLException
{
String sql = "select top 1 getDate() from a_sys_user";
String file_path = "errorLog.txt";
int is_Success = 0;
is_Success=outputFile(sql,file_path);
return is_Success;
}public static int outputFile(String sql_in,String file_path) throws IOException,SQLException
{
ConnectionManager db = ConnectionManager.getInstance();
Connection con = db.getConnection();
Statement st = con.createStatement();
ResultSet rs = null;
ResultSetMetaData rsmd = null;
int ColumnCount = 0;
int RowCount = 0;
int i = 0;
String sql = sql_in;
String str = "";
String sepa = System.getProperty("line.separator");
File outfile = null;
FileWriter fw = null;
try{
outfile = new File(file_path);
fw = new FileWriter(outfile);
if(sql_in!=null)
sql=sql_in;
rs = st.executeQuery(sql);
rsmd = rs.getMetaData();
ColumnCount = rsmd.getColumnCount();
//System.out.println(ColumnCount);
//rs.next();
while(rs.next())
{
for(i=1;i<=ColumnCount;i++)
{
str+=rs.getString(i)+"\t";
//System.out.print(rs.getString(i)+"\t");
}
fw.write(str,0,str.length());
fw.write(sepa);
//System.out.println(sepa);
str = "";
RowCount++;
}}
catch(IOException ex1)
{
//ex1.printStackTrace();
RowCount=-10;
}
catch(SQLException ex2)
{
//ex2.printStackTrace();
RowCount=-20;
}
catch(NullPointerException ex3)
{
//ex3.printStackTrace();
RowCount=-20;
}
finally
{
fw.flush();
rs.close();
st.close();
db.close(con);
fw.close();
}
return RowCount;
}
}