java财务系统源码
import java.util.*;
class ThreadTest {
static int type = 4, num = 10; //定义资源数目和线程数目
static int[] resource = new int[type]; //系统资源总数
//static int[] Resource = new int[type]; //副本
static Random rand = new Random();
static Bank[] bank = new Bank[num]; //线程组
Bank temp = new Bank();
public void init() {
//初始化组中每个线程,随机填充系统资源总数
for(int i = 0; i < type; i++)
resource[i] = rand.nextInt(10) + 80;
System.out.print("Resource:");
for(int i = 0; i < type; i++)
System.out.print(" " + resource[i]);
System.out.println("");
for(int i = 0; i < bank.length; i++)
bank[i] = new Bank("#" + i);
}
public ThreadTest4() {
init();
}
class Bank extends Thread {
//银行家算法避免死锁
public int[]
max = new int[type], //总共需求量
need = new int[type], //尚需资源量
allocation = new int[type]; //已分配量
private int[]
request = new int[type], //申请资源量
Resource = new int[type]; //资源副本
private boolean isFinish = false; //线程是否完成
int[][] table = new int[bank.length][type*4]; //二维资源分配表
private void init() {
// 随机填充总共、尚需、已分配量
synchronized(resource) {
for(int i = 0; i < type; i++) {
max[i] = rand.nextInt(5) + 10;
need[i] = rand.nextInt(10);
allocation[i] = max[i] - need[i];
resource[i] -= allocation[i]; //从系统资源中减去已分配的
}
printer();
for(int i = 0; i < type; i++) {
if(resource[i] < 0) {
//若出现已分配量超出系统资源总数的错误则退出
System.out.println("The summation of Threads' allocations is out of range!");
System.exit(1);
}
}
}
}
public Bank(String s) {
setName(s);
init();
start();
}
public Bank() {
//none
}
public void run() {
try {
sleep(rand.nextInt(2000));
}
catch(InterruptedException e) {
throw new RuntimeException(e);
}
while(true) {
//程序没有完成时一直不断申请资源
if(askFor() == false) {
try {
sleep(1000);
}
catch(InterruptedException e) {
throw new RuntimeException(e);
}
}
else
tryRequest();
if(noNeed() == true)
break;
}
//休眠一段时间模拟程序运行
try {
sleep(1000);
}
catch(InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println(getName() + " finish!");
synchronized(resource) {
//运行结束释放占有资源
for(int i = 0; i < type; i++) {
resource[i] += allocation[i];
need[i] = allocation[i] = max[i] = 0;
}
}
}
private void printer() {
//打印当前资源信息
System.out.print(getName() + " Max:");
for(int i = 0; i < type; i++)
System.out.print(" " + max[i]);
System.out.print(" Allocation:");
for(int i = 0; i < type; i++)
System.out.print(" " + allocation[i]);
System.out.print(" Need:");
for(int i = 0; i < type; i++)
System.out.print(" " + need[i]);
System.out.print(" Available:");
for(int i = 0; i < type; i++)
System.out.print(" " + resource[i]);
System.out.println("");
}
private boolean askFor() {
//随机产生申请资源量并检测是否超标
boolean canAsk = false;
for(int i = 0; i < type; i++) {
request[i] = rand.nextInt(20);
//防止申请量超过所需量
if(request[i] > need[i])
request[i] = need[i];
}
for(int i = 0; i < type; i++) //防止随机申请资源全为0
if(request[i] > 0)
canAsk = true;
synchronized(resource) {
//锁住可供资源检查是否超标
for(int i = 0; i < type; i++) {
if(request[i] > resource[i])
//如果申请资源超过可供资源则等待一段时间后重新申请
return false;
}
}
return canAsk;
}
private void tryRequest() {
//创建副本尝试分配请求
synchronized(resource) {
for(int i = 0; i < type; i++)
//依然要防止请求量超出范围
if(request[i] > resource[i])
return;
for(int i = 0; i < type; i++) {
//复制资源量并减去需求量到一个副本上
Resource[i] = resource[i];
Resource[i] -= request[i];
}
System.out.print(getName() + " ask for:");
for(int i = 0; i < type; i++)
System.out.print(" " + request[i]);
System.out.println("");
if(checkSafe() == true) {
//如果检查安全则将副本值赋给资源量并修改占有量和需求量
for(int i = 0; i < type; i++) {
resource[i] = Resource[i];
allocation[i] += request[i];
need[i] -= request[i];
}
System.out.println(getName() + " request succeed!");
}
else
System.out.println(getName() + " request fail!");
}
}
private boolean checkSafe() {
//银行家算法检查安全性
synchronized(bank) {
//将线程资源信息放入二维资源分配表检查安全性,0~type可用资源/type~type*2所需资源/type*2~type*3占有资源/type*3~-1可用+占用资源
for(int i = 0; i < bank.length; i++) {
for(int j = type; j < type*2; j++) {
table[i][j] = bank[i].need[j%type];
}
for(int j = type*2; j < type*3; j++) {
table[i][j] = bank[i].allocation[j%type];
}
}
//冒泡排序按需求资源从小到大排
for(int i = 0; i < bank.length; i++) {
for(int j = i; j < bank.length-1; j++) {
sort(j, 4);
}
}
//进行此时刻的安全性检查
for(int i = 0; i < type; i++) {
table[0][i] = Resource[i];
table[0][i+type*3] = table[0][i] + table[0][i+type*2];
if(table[0][i+type*3] < table[1][i+type])
return false;
}
for(int j = 1; j < bank.length-1; j++) {
for(int k = 0; k < type; k++) {
table[j][k] = table[j-1][k+type*3];
table[j][k+type*3] = table[j][k] + table[j][k+type*2];
if(table[j][k+type*3] < table[j+1][k+type])
return false;
}
}
}
return true;
}
private void sort(int j, int k) {
//递归冒泡排序
int tempNum;
if(table[j][k] > table[j+1][k]) {
for(int i = type; i < type*2; i++) {
tempNum = table[j][i];
table[j][i] = table[j+1][i];
table[j+1][i] = tempNum;
}
/*temp = bank[j];
bank[j] = bank[j+1];
bank[j+1] = temp;*/
}
else if(table[j][k] == table[j+1][k] && k < type*2) //此资源量相同时递归下一个资源量排序并且防止超出范围
sort(j, k+1);
}
private boolean noNeed() {
//是否还需要资源
boolean finish = true;
for(int i = 0; i < type; i++) {
if(need[i] != 0) {
finish = false;
break;
}
}
return finish;
}
}
public static void main(String[] args) {
ThreadTest t = new ThreadTest();
//后台线程,设定程序运行多长时间后自动结束
new Timeout(30000, "---Stop!!!---");
}
}
❷ Shark(鲨鱼记账系统)–附源码
Shark(鲨鱼记账系统)–附源码
package com.shayu.note;
import java.util.Scanner;
public class SharkSystem {
// //下面开始循环
while (flag) {
//或蔽开机界面
System.out.println("-----欢迎使用鲨鱼记账系统-----");
System.out.println("1,收支明细");
System.out.println("2,登记收入");
System.out.println("3,登记支出");
System.out.println("4,退出系统");
System.out.println("请按照提衫郑州示选择你要使丛孝用的的功能--");
Scanner scanner = new Scanner(System.in);//判断用户输入是否符合要求
int choice = scanner.nextInt();//选择
//检测用户输入的数据并返回相应的请求结果
while (choice != 1 & choice != 2 & choice != 3 & choice != 4) {
System.out.println("请重新输入--");
int newchoice = scanner.nextInt();
choice = newchoice;
}
}
package com.shayu.note;
import java.util.Scanner;
//鲨鱼记账系统
public class Shark {
public static void main(String[] args) {
SharkSystem shark=new SharkSystem();
shark.StartSystem();
}
}
❸ 求编写一个超级简单的Java的程序源代码
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class Caculator extends JFrame implements ActionListener,KeyListener{
private JTextField tf=new JTextField();
private float x=0;
private float y=0;
private int code=0;
private boolean enable;
private boolean first;
private String str="";
public Caculator(){
Container ct=this.getContentPane();
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
tf.setHorizontalAlignment(JTextField.RIGHT);
//tf.setText("0");
enable=true;
first=true;
ct.add(tf,BorderLayout.NORTH);
JPanel panel=new JPanel();
panel.setLayout(new GridLayout(4,4));
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
if(JOptionPane.YES_OPTION==JOptionPane.showConfirmDialog(Caculator.this,"确定要关闭程序吗?","提示",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE)){
e.getWindow().setVisible(false);
e.getWindow().dispose();
System.exit(0);
}
}
});
Button btn=null;
btn=new Button("1");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("2");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("3");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("+");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("4");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("5");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("6");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("-");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("7");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("8");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("9");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("*");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("0");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button(".");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("/");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
btn=new Button("=");
panel.add(btn);
btn.addActionListener(this);
btn.addKeyListener(this);
this.add(panel,BorderLayout.CENTER);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Caculator mainframe=new Caculator();
mainframe.setTitle("testing Caculator");
mainframe.setSize(400,400);
mainframe.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand()=="+"){
x= Float.parseFloat(tf.getText());
code=0;
this.tf.setText("");
}
if(e.getActionCommand()=="-"){
x= Float.parseFloat(tf.getText());
code=1;
this.tf.setText("");
}
if(e.getActionCommand()=="*"){
x= Float.parseFloat(tf.getText());
code=2;
this.tf.setText("");
}
if(e.getActionCommand()=="/"){
x= Float.parseFloat(tf.getText());
code=3;
this.tf.setText("");
}
if(e.getActionCommand()!="+"&&e.getActionCommand()!="-"&&e.getActionCommand()!="*"&&e.getActionCommand()!="/"&&e.getActionCommand()!="="){
if(enable){
if(first){
System.out.println("haha");
tf.setText(e.getActionCommand());
first=false;
}
else {
tf.setText(tf.getText()+e.getActionCommand());
}
}
else {
tf.setText(e.getActionCommand());
enable=true;
}
}
if(e.getActionCommand()=="="){
switch(code){
case 0:
y=x+Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 1:
y=x-Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 2:
y=x*Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 3:
y=x/Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
}
}
}
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if(e.getKeyChar()=='+'){
x= Float.parseFloat(tf.getText());
code=0;
this.tf.setText("");
}
if(e.getKeyChar()=='-'){
x= Float.parseFloat(tf.getText());
code=1;
this.tf.setText("");
}
if(e.getKeyChar()=='*'){
x= Float.parseFloat(tf.getText());
code=2;
this.tf.setText("");
}
if(e.getKeyChar()=='/'){
x= Float.parseFloat(tf.getText());
code=3;
this.tf.setText("");
}
if(e.getKeyChar()=='1'||e.getKeyChar()=='2'||e.getKeyChar()=='3'||e.getKeyChar()=='0'
||e.getKeyChar()=='4'||e.getKeyChar()=='5'||e.getKeyChar()=='6'||e.getKeyChar()=='.'
||e.getKeyChar()=='7'||e.getKeyChar()=='8'||e.getKeyChar()=='9'){
System.out.println("hai");
if(enable){
if(first){
System.out.println("hehe");
str=Character.toString(e.getKeyChar());
tf.setText(str);
first=false;
}
else {
str=Character.toString(e.getKeyChar());
tf.setText(tf.getText()+str);
}
}
else {
str=Character.toString(e.getKeyChar());
tf.setText(str);
enable=true;
}
}
if(e.getKeyCode()==KeyEvent.VK_ENTER){
switch(code){
case 0:
y=x+Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 1:
y=x-Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 2:
y=x*Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
case 3:
y=x/Float.parseFloat(this.tf.getText());
tf.setText(Float.toString(y));
enable=false;
break;
}
}
}
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
}
❹ 求个好用的java网上商城源码。
我们的项目是基于shop++二次开发的,仅供参考~
❺ 求编写一个超级简单的Java的程序源代码
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Login {
public static void main(String args[]) {
LoginFrm frame = new LoginFrm();
}
}
class LoginFrm extends JFrame implements ActionListener{
JLabel nameLabel=new JLabel("用户名:");
JLabel pwdLabel=new JLabel("密码:");
JTextField name=new JTextField(10);
JPasswordField password=new JPasswordField(10);
JButton butnSure=new JButton("确定");
JButton butnCancel=new JButton("取消");
public LoginFrm() {
super("登陆");
setBounds(500, 200, 280, 220);
setVisible(true);
setLayout(null);
nameLabel.setBounds(45, 20, 100, 25);
add(nameLabel);
add(name);
name.setBounds(105, 20, 110, 25);
add(pwdLabel);
pwdLabel.setBounds(45, 60, 100, 25);
add(password);
password.setBounds(105, 60, 110, 25);
add(butnSure);
butnSure.setBounds(45, 100, 80, 25);
add(butnCancel);
butnCancel.setBounds(135, 100, 80, 25);
butnSure.addActionListener(this);
butnCancel.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();//刷新橡猜
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() ==butnSure){
System.out.println("用户名:"+name.getText());
System.out.println("密码:"+name.getText());
if("admin".equals(name.getText().trim())&&"123".equals(password.getText().trim())){
this.dispose();
new MainFrm("码迅用户界面",name.getText().trim(),password.getText().trim());
}else {
JOptionPane.showMessageDialog(this, "用迟如此户不存在");
}
}else if(e.getSource()==butnCancel){
System.exit(1);
}
}
class MainFrm extends JFrame{
private JLabel info;
public MainFrm(String s,String name,String password) {
super(s);
setBounds(400, 200, 500, 400);
setLayout(new FlowLayout());
info=new JLabel("登陆成功,用户名:"+name+",密码:"+password);
add(info);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();
}
}
}
❻ 什么是java源代码 怎么查看
不知道你说的是浏览器的还是什么的,
如果是浏览器的那么简单找到工具-查看源代码,你就能看见代码了,
还有一个就是被编译成class文件的java用反编译工具可以看到源代码,
如果以上都不是你想要的答案,那么你所说的代码就是程序员写好的代码文件
❼ 用java来编写一个银行类账户和信用卡类的账户,信用卡类账户继承银行账户,求源码
public class Account {
protected String accId;
protected String name;
protected double money;
public Account (String accId,String name){
this(accId,name,0);
}
public Account (String accId,String name,double money){
this.accId = accId;
this.name = name;
this.money = money;
}
public void saveMoney(double money){
if(money <= 0){
System.out.println("存款金额必须大于0");
}
this.money += money;
System.out.println("存款成功");
}
public double getMoney(double money){
if(money <= 0){
System.out.println("取款金额必须大于0");
return 0;
}
if(this.money <= money){
System.out.println("余额不足,无法取款");
return 0;
}
this.money -= money;
System.out.println("取款成功");
return money;
}
public double getBalance(){
return this.money;
}
protected double getOverdraft(){
return 0;
}
// 实现了equals方法,list比较时才能正确
@Override
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if(this == obj){
return true;
}
if(obj instanceof Account){
return this.accId.equals(((Account)obj).accId);
}
return false;
}
@Override
public String toString() {
return "账户=" + accId + ",名字=" + name + ",余额=" + money;
}
}
public class Bank {
// Account实现了equals方法,list查找时才能正确
private List<Account> usersAccounts;
public Bank() {
usersAccounts = new ArrayList<Account>();
}
public void addAccount(Account account) {
if (usersAccounts.contains(account)) {
System.out.println("添加失败,不能添加同样的账户");
return;
}
usersAccounts.add(account);
}
public boolean delAccount(Account account) {
return usersAccounts.remove(account);
}
public boolean delAccount(String accId) {
return delAccount(new Account(accId, null));
}
public boolean existAccount(Account account) {
return usersAccounts.contains(account);
}
public boolean existAccount(String accId) {
return existAccount(new Account(accId, null));
}
public Account getAccount(String accId){
return usersAccounts.get(usersAccounts.indexOf(new Account(accId, null)));
}
public double getAllMoney() {
// 不考虑是否溢出,只是把所有用户余额相加
double result = 0;
for (Account account : usersAccounts) {
result += account.getBalance();
}
return result;
}
public double getAllOverdraft() {
// 不考虑是否溢出
double result = 0;
for (Account account : usersAccounts) {
result += account.getOverdraft();
}
return result;
}
public int getAccountNum() {
return usersAccounts.size();
}
public int getCreditAccountNum() {
int num = 0;
for (Account account : usersAccounts) {
// instanceof 性能没有简单的方法快。
if (account instanceof CreditAccount) {
num++;
}
}
return num;
}
public int getSavingAccountNum() {
int num = 0;
for (Account account : usersAccounts) {
if (account instanceof SavingAccount) {
num++;
}
}
return num;
}
public List<Account> getAllAccount() {
return usersAccounts;
}
}
public class CreditAccount extends Account{
private double overdraft;
public CreditAccount(String accId,String name){
super(accId, name);
this.overdraft = 1000;
}
public CreditAccount(String accId,String name,double money){
this(accId, name,money,1000);
}
public CreditAccount(String accId,String name,double money,double overdraft){
super(accId, name,money);
this.overdraft = overdraft;
}
@Override
public double getMoney(double money) {
if(money <= 0){
System.out.println("取款金额必须大于0");
return 0;
}
if(this.money + overdraft <= money){
System.out.println("余额不足,无法取款");
return 0;
}
this.money -= money;
System.out.println("取款成功");
return money;
}
@Override
public double getOverdraft(){
return overdraft;
}
@Override
public String toString() {
return "账户=" + accId + ",名字=" + name + ",余额=" + money + ",透支=" + overdraft;
}
}
public class SavingAccount extends Account {
public SavingAccount(String accId, String name) {
super(accId, name);
}
public SavingAccount(String accId, String name, double money) {
super(accId, name, money);
}
@Override
public double getMoney(double money) {
return super.getMoney(money);
}
@Override
public double getOverdraft() {
return super.getOverdraft();
}
}
public class Test {
private static Bank bank = new Bank();
public static void main(String[] args) {
Test.genAccount();
// 开户
Account a1 = new CreditAccount("1", "1", 200, 2000);
Account a2 = new SavingAccount("2", "2", 300);
Account a3 = new SavingAccount("3", "3", 400);
Account a4 = new CreditAccount("4", "4", 500, 2000);
Account a5 = new CreditAccount("4", "5", 600, 2000); // 帐号4重
bank.addAccount(a1);
bank.addAccount(a2);
bank.addAccount(a3);
bank.addAccount(a4);
bank.addAccount(a5);
showNowAccount();
// 销户
bank.delAccount("1");
bank.delAccount("2");
showNowAccount();
// 存款
if(bank.existAccount("3")){
Account acc = bank.getAccount("3");
acc.saveMoney(100);
}
showNowAccount();
// 取款
if(bank.existAccount("3")){
Account acc = bank.getAccount("3");
System.out.println("余额=" + acc.getBalance());
acc.getMoney(100);
System.out.println("余额=" + acc.getBalance());
acc.getMoney(1000);
System.out.println("余额=" + acc.getBalance());
}
if(bank.existAccount("4")){
Account acc = bank.getAccount("4");
System.out.println("余额=" + acc.getBalance());
acc.getMoney(100);
System.out.println("余额=" + acc.getBalance());
acc.getMoney(1000);
System.out.println("余额=" + acc.getBalance());
acc.getMoney(10000);
System.out.println("余额=" + acc.getBalance());
}
System.out.println(bank.getAccountNum());
System.out.println(bank.getAllMoney());
System.out.println(bank.getAllOverdraft());
System.out.println(bank.getCreditAccountNum());
System.out.println(bank.getSavingAccountNum());
}
public static void genAccount(){
String s = "1000 0000 0000 000";
Account a = null;
for(int i = 1; i < 11; i ++){
if((i & 2) == 0){
a = new CreditAccount(s + String.valueOf(i), "账户" + String.valueOf(i));
} else {
a = new SavingAccount(s + String.valueOf(i), "账户" + String.valueOf(i));
}
bank.addAccount(a);
}
}
public static void showNowAccount(){
for(Account account : bank.getAllAccount()){
System.out.println(account);
}
}
}
❽ 跪求一个小型超市管理系统,用java编写的,急~ 只要源代码。。可以发我邮箱
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Conn {
private static final String driver="com.mysql.jdbc.Driver";
private static final String url="jdbc:mysql://localhost:3306/blog?user=root&password=root";
//获得数据库连接
public static Connection getConnection(){
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url);
if(conn != null){
System.out.print("成功");
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return conn;
}
//关闭Resultset
public static void closeResultSet(ResultSet rs)
{
try
{
if(rs != null)
{
rs.close();
}
}catch (SQLException ex)
{
ex.printStackTrace();
}
}
//关闭Statement
public static void closeStatement(Statement st)
{
try
{
if(st != null)
{
st.close();
}
}catch (SQLException ex)
{
ex.printStackTrace();
}
}
//关闭Connection
public static void closeConnection(Connection conn)
{
try
{
if(conn != null)
{
conn.close();
}
}catch (SQLException ex)
{
ex.printStackTrace();
}
}
//测试数据库连接是否成功
public static void main(String[] args) {
Conn.getConnection();
}
}