只有注册用户登录后才能阅读该文。
阅读全文
在java中DecimalFormat 是表示格式的,例如
double avprice="28234.2534";
java.text.DecimalFormat df =new java.text.DecimalFormat("#.00");
String aveprice=df.format(avprice);
这种写法就是整数保留不变,后面保留2位小数,不足则补0
在oracle里有时需要查询结果就保持格式
to_char(col_name,'99999D99')
这表示整数保持5位,小数2位,如果把9改成0,就是强制补0
package Test;
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class TestConnect {
public TestConnect() {
}
static Connection con = null;
public static void main(String args[]) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//String url="jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=D://demo.mdb";
String url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D://demo.mdb";
//String url = "jdbc:odbc:Access";
con = DriverManager.getConnection(url,"","");
Statement stmt = con.createStatement();
String sql = "select * from base";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
System.out.println("name= " + rs.getString(1));
}
rs.close();
stmt.close();
con.close();
//JakartaBasicDataSource.closeBasicDataSourceConnection();
}
catch (Exception e) {
e.printStackTrace();
System.out.println("now you have not ActiveConnection..........break!!");
}
}
}