package untitled3;
import java.sql.*;
public class ConnectionDB {
public ConnectionDB() {
}
public static Connection connection(){
Connection con=null;
String CLASSFORNAME = "org.postgresql.Driver";
String SERVANDDB ="jdbc:postgresql://localhost/jxfdc";
String USER = "postgres";
String PWD = "chonghua";
try {
Class.forName(CLASSFORNAME);
con = DriverManager.getConnection(SERVANDDB, USER, PWD);
}
catch (Exception e) {
e.printStackTrace();
}
return con;
}public static void main(String args[]){
try{
Connection con = ConnectionDB.connection();
Statement stmt = con.createStatement();
ResultSet rst=stmt.executeQuery("select * from userinfo");
while(rst.next()){
System.out.println(rst.getString(1)+" "+rst.getString(2));
}
rst.close();
stmt.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}}
}
import java.sql.*;
public class ConnectionDB {
public ConnectionDB() {
}
public static Connection connection(){
Connection con=null;
String CLASSFORNAME = "org.postgresql.Driver";
String SERVANDDB ="jdbc:postgresql://localhost/jxfdc";
String USER = "postgres";
String PWD = "chonghua";
try {
Class.forName(CLASSFORNAME);
con = DriverManager.getConnection(SERVANDDB, USER, PWD);
}
catch (Exception e) {
e.printStackTrace();
}
return con;
}public static void main(String args[]){
try{
Connection con = ConnectionDB.connection();
Statement stmt = con.createStatement();
ResultSet rst=stmt.executeQuery("select * from userinfo");
while(rst.next()){
System.out.println(rst.getString(1)+" "+rst.getString(2));
}
rst.close();
stmt.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}}
}
解决方案 »
- 求解决方法!急
- Struts 2 根本不存在 鍒嗛殧绗?gif action name 有这种错,郁闷啊!!!
- 用Java本身对Oracle 备份
- 如何提升表的插入更新速度。表中记录在2000w左右
- jacob调用c写的com!!!!!!!急!急!急!急!急!急!急!急!
- 急!!!!!!
- 设置一个servlet在tomcat启动时候启动,并作定时操作。但这个servlet在init()时却停止了tomcat的启动,FT。。。
- 初学JNDI的错误
- 排序问题
- tomcat公用session的问题,非常奇怪。
- 关于JBoss的服务问题(急急急!!!)
- 请教struts中多个struts-config.xml文件的配置和使用问题,能否提供一些tiles的资料和使用方法
* EsfjyqkBean.java
*
* Created on 2005年7月28\uFFFD\uFFFD, 下午12:39
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/package javaBean;
import java.util.*;
import java.sql.*;
/**
*java.sql.Timestamp
* @author wangwei
*/
public class EsfjyqkBean implements SbsjInterface{
public EsfjyqkBean(){
this.tablename="esfjyqk";
java.util.Date myday=(new java.util.Date());
tbsj= new java.sql.Timestamp(myday.getTime());
} private int id;
private int dwlx;
private String diquno;
private String sbsj;
private String tablename;
private java.sql.Timestamp tbsj;
private Connection con=null;
private PreparedStatement pstmt=null;
private Statement stmt=null;
private ResultSet rs=null;
private String sql="";
private float f1;
private float f2;
private float f3;
private int f4;
private float f5;
private float f6;
private int f7;
private float f8;
private int f9;
private int f10;
private int f11;
private int f12;
private int f13;
private int f14;
private int f15;
private int f16;
private int f17;
private int f18;
private int f19;
private int f20;
private int f21;
private int f22;
private int f23;
private int f24;
private int f25;
private int f26;
private int f27;
public void setId(int id){
this.id=id;
}
public int getId(){
return id;
}
public void setDwlx(int dwlx){
this.dwlx=dwlx;
}
public int getDwlx(){
return dwlx;
}
public void setDiquno(String diquno){
this.diquno=diquno;
}
public String getDiquno(){
return diquno;
}
public void setSbsj(String sbsj){
this.sbsj=sbsj;
}
public String getSbsj(){
return sbsj;
}
public void setTbsj(java.sql.Timestamp tbsj){
this.tbsj=tbsj;
}
public java.sql.Timestamp getTbsj(){
return tbsj;
}
public void setF1(float f1){
this.f1=f1;
}
public float getF1(){
return f1;
}
public void setF2(float f2){
this.f2=f2;
}
public float getF2(){
return f2;
}
public void setF3(float f3){
this.f3=f3;
}
public float getF3(){
return f3;
}
public void setF5(float f5){
this.f5=f5;
}
public float getF5(){
return f5;
}
public void setF6(float f6){
this.f6=f6;
}
public float getF6(){
return f6;
}
public void setF8(float f8){
this.f8=f8;
}
public float getF8(){
return f8;
}
public void setF4(int f4){
this.f4=f4;
}
public int getF4(){
return f4;
}
public void setF7(int f7){
this.f7=f7;
}
public int getF7(){
return f7;
}
public void setF9(int f9){
this.f9=f9;
}
public int getF9(){
return f9;
}
public void setF10(int f10){
this.f10=f10;
}
public int getF10(){
return f10;
}
public void setF11(int f11){
this.f11=f11;
}
public int getF11(){
return f11;
}
public void setF12(int f12){
this.f12=f12;
}
public int getF12(){
return f12;
}
public void setF13(int f13){
this.f13=f13;
}
public int getF13(){
return f13;
}
public void setF14(int f14){
this.f14=f14;
}
public int getF14(){
return f14;
}
public void setF15(int f15){
this.f15=f15;
}
public int getF15(){
return f15;
}
public void setF16(int f16){
this.f16=f16;
}
public int getF16(){
return f16;
}
public void setF17(int f17){
this.f17=f17;
}
public int getF17(){
return f17;
}
public void setF18(int f18){
this.f18=f18;
}
public int getF18(){
return f18;
}
public void setF19(int f19){
this.f19=f19;
}
public int getF19(){
return f19;
}
public void setF20(int f20){
this.f20=f20;
}
public int getF20(){
return f20;
}
public void setF21(int f21){
this.f21=f21;
}
public int getF21(){
return f21;
}
public void setF22(int f22){
this.f22=f22;
}
public int getF22(){
return f22;
}
public void setF23(int f23){
this.f23=f23;
}
public int getF23(){
return f23;
}
public void setF24(int f24){
this.f24=f24;
}
public int getF24(){
return f24;
}
public void setF25(int f25){
this.f25=f25;
}
public int getF25(){
return f25;
}
public void setF26(int f26){
this.f26=f26;
}
public int getF26(){
return f26;
}
public void setF27(int f27){
this.f27=f27;
}
public int getF27(){
return f27;
}