java 操作ORACLE数据库问题 项目中要求所以有的INSERT语句都要写到properties文件中,通过读配置文件把记录写到数据库中,请问哪位高手做过类似的项目啊。给个例子,谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写个读取properties文件的方法,通过键读取值,或者用ibatis吧! java访问资源文件Java code import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Properties; public class PropertyEditor { public static void main(String[] args) throws Exception { Properties prop = new Properties();// 属性集合对象 FileInputStream fis = new FileInputStream("prop.properties");// 属性文件输入流 (相对于根目录下的文件名,要加上包名 “src/prop.properties”) prop.load(fis);// 将属性文件流装载到Properties对象中 fis.close();// 关闭流 // 获取属性值,sitename已在文件中定义 System.out.println("获取属性值:sitename=" + prop.getProperty("sitename")); // 获取属性值,country未在文件中定义,将在此程序中返回一个默认值,但并不修改属性文件 System.out.println("获取属性值:country=" + prop.getProperty("country", "中国")); // 修改sitename的属性值 prop.setProperty("sitename", "中国"); // 添加一个新的属性studio prop.setProperty("studio", "Boxcode Studio"); // 文件输出流 FileOutputStream fos = new FileOutputStream("prop.properties"); // 将Properties集合保存到流中 prop.store(fos, "Copyright (c) Boxcode Studio"); fos.close();// 关闭流 } } 资源文件sitename=\u4E2D\u56FDsiteurl=www.abcjava.com studio=Boxcode Studio 读取properties没有试过、但读取自定义xml用dom4j蛮方便的. 关键是读取出Properties文件中的SQL读取Properties属性文件用Java自带的API就ok了,很简单 用了properties 估计还有转义字符等一大堆问题,还不如直接用xml,或者用mybatis吧,省力些 现在处理就是只写INSERT语句在properties文件中了。因为有好多配置文个把,包括数据库连接配置文件和log4j配置文件。现在需要把这三个文件打成架包,请问哪位做过类似的把配置文件打成架包的? 问个exe安装程序问题 纳闷的一个举动,编写规范问题 关于泛型的类型转换 Oracle JDBC 问题 如何得到字符的ascii码? 很简单的程序,但是有大麻烦 如何调用不同盘幅下的包。。 请问有没有关于使用JCreator的教程,谢谢!30分 !~~~~~~~~~~~推荐一下,大家都是在哪找的例子哪? 请问那位老师有JAVA的API文档资料请发给小弟:[email protected] java 抓取cd音轨 open resource 用java的MulticastSocket实现的组播,在无线环境下接收不到数据包是怎么回事?求大牛们解释啊
import java.io.FileOutputStream;
import java.util.Properties;
public class PropertyEditor {
public static void main(String[] args) throws Exception {
Properties prop = new Properties();// 属性集合对象
FileInputStream fis = new FileInputStream("prop.properties");// 属性文件输入流 (相对于根目录下的文件名,要加上包名 “src/prop.properties”)
prop.load(fis);// 将属性文件流装载到Properties对象中
fis.close();// 关闭流
// 获取属性值,sitename已在文件中定义
System.out.println("获取属性值:sitename=" + prop.getProperty("sitename"));
// 获取属性值,country未在文件中定义,将在此程序中返回一个默认值,但并不修改属性文件
System.out.println("获取属性值:country=" + prop.getProperty("country", "中国"));
// 修改sitename的属性值
prop.setProperty("sitename", "中国");
// 添加一个新的属性studio
prop.setProperty("studio", "Boxcode Studio");
// 文件输出流
FileOutputStream fos = new FileOutputStream("prop.properties");
// 将Properties集合保存到流中
prop.store(fos, "Copyright (c) Boxcode Studio");
fos.close();// 关闭流
}
}
资源文件sitename=\u4E2D\u56FD
siteurl=www.abcjava.com
studio=Boxcode Studio
或者用mybatis吧,省力些
因为有好多配置文个把,包括数据库连接配置文件和log4j配置文件。现在需要把这三个文件打成架包,
请问哪位做过类似的把配置文件打成架包的?