博文
数据库连接简单事例(2006-04-06 16:44:00)
摘要:import java.sql.*;import javax.swing.*;
class jdbcExample1{ public static void main(String args[]){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:studyDSN"; String login="sa"; String password=""; Connection conn=DriverManager.getConnection(url,login,password); Statement statement=conn.createStatement(); String sqlQuery="select * from course"; ResultSet rs=statement.executeQuery(sqlQuery); while(rs.next()){ System.out.print(rs.getString(1)+","); System.out.print(rs.getString(2)+","); System.out.print(rs.getInt(3)+","); } statement.close(); conn.close(); } catch(SQLException sqlException){......
java时钟程序(图片文本筐)(2006-04-06 07:36:00)
摘要:import java.awt.*;import javax.swing.*;import java.util.*;
//定义测试类//所有变量名冲突的变量名串1了,不过就效果不好~~public class TimerTest{ //定义主函数 public static void main(String[] args) { //定义JFrame类的一个对象,并创建该对象 MyTimer1 f = new MyTimer1(); //调用MyTimer的show()方法 f.show(); //---------------------------------------------------- //调用类的构造函数 MyTimer myTimer=new MyTimer(); //调用类的显示时间函数 myTimer.displayCurrentTime(); //调用类的设置时间函数 myTimer.setCurrentTime(); //调用类的显示时间函数 myTimer.displayCurrentTime(); //调用类的显示时间函数 myTimer.displayCurrentTime(); System.exit(0); }}
//定义MyTimer类class MyTimer1 extends JFrame{ static int count=0; //判断是否重定义了时......
java计算器(2006-04-05 00:36:00)
摘要:import java.awt.*;import java.lang.*;import javax.swing.*;import javax.swing.event.*;import java.awt.event.*;import java.text.DecimalFormat;public class Calculator implements ActionListener { //导入动作监听接口 //设计面板中的单位 JFrame frame; JTextField textAnswer; JPanel panel, panel1, panel2, panel3; JMenuBar mainMenu; JTextField textMemory; JLabel labelMemSpace; //labelMemSpace单纯做摆设,控制面板的形状 JButton buttonBk, buttonCe, buttonC; JButton button[]; JButton buttonMC, buttonMR, buttonMS, buttonMAdd; JButton buttonDot, buttonAddAndSub, buttonAdd, buttonSub, buttonMul, buttonDiv, buttonMod; JButton buttonSqrt, buttonDao, buttonEqual; JMenu editMenu, viewMenu, helpMenu; JMenuItem copyItem, pasteItem, tItem, sItem, numberGroup, topHelp, aboutCal; DecimalFormat df; //设置数据输出精度 boolean clickable; //控制当前能否按键 double memoryd; //使用内存中存储的数字 int memoryi; do......
书上的线程GUI(2006-04-05 00:25:00)
摘要:import java.awt.*;import java.awt.event.*;public class Welcome extends WindowAdapter implements ActionListener{ Frame f; static Welcome.Thread3 wt1,wt2; public static void main(String args[]){ Welcome w=new Welcome(); w.display(); wt1=w.new Thread3("welcome!"); wt2=w.new Thread3("how are you?"); wt2.start(); wt2.setButton(); } public void display(){ f=new Frame("welcome"); f.setSize(400,240); f.setLocation(200,140); f.setBackground(Color.lightGray); f.setLayout(new GridLayout(4,1)); f.addWindowListener(this); f.setVisible(true); } public class Thread3 extends Thread{ Panel p1; Label lb1; TextField tf1,tf2; Button b1,b2; int sleeptime=(int)(Math.random()*100); public Thread3(String str){ super(str); for(int i=0;i&......
书上标准输入输出(有错误)(2006-04-04 11:14:00)
摘要:import java.io.*;class PromptAndEcho{ public static void main(String args[]) throws IOException{ if(args.length()<1){ System.err.println("java Prompt And Echo <output file>"); return;} BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(new FileOutputStream(args[0])); while(true){ System.out.print("input>"); String s=stdin.readLine(); if(s.equalsLgnoreCase("exit")) break; System.out.println(s); pw.println(s);} pw.close(); stdin.close(); } } ......
让自己学会写的一个在线升级的程序 (2006-04-03 20:55:00)
摘要:void CUpdateDlg::OnButtonDoupdate() { // 读取升级文件 CFileStatus rStatus; CString szIniData; CString inFile; CString tmp; inFile=m_szPath+"\\update.ini"; CFile UpdateFile; UpdateFile.Open( inFile, CFile::modeRead); UpdateFile.GetStatus(inFile,rStatus); UpdateFile.Read(szIniData.GetBuffer(rStatus.m_size),rStatus.m_size); UpdateFile.Close(); CStringArray arType; CStringArray arVersion; for(int i=1;i<=27;i+=2){ AfxExtractSubString(tmp,szIniData,i,'\n'); tmp.TrimRight(); tmp.TrimRight(); arType.Add(tmp); } for(int j=2;j<=28;j+=2){ AfxExtractSubString(tmp,szIniData,j,'\n'); tmp.TrimRight(); tmp.TrimRight(); arVersion.Add(tmp); } GetDlgItem(IDC_BUTTON_DOUPDATE)->EnableWindow(FALSE); CProgressCtrl* pBar = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS_UPDATE); pBar->SetPos(5); m_szEditMessage = "\r\n取得网络升级地址\r\n"+ServerUrl; UpdateData(FALSE); CInternetSession mySession(NULL,0); CHttpFile* myHttpFile=NULL; BOOL bIsNewer = FALSE; CString myData; ......
本人的文本输入(目前只有分数文本可用)(2006-04-02 23:59:00)
摘要:import java.awt.*;import java.awt.event.*;import javax.swing.*;
public class ButtonTest1 extends JFrame{ private JButton aB,bB,exitButton,qrButton; private JLabel mz,fs; private JTextField mz1,fs1; public String mzsz[]=new String[20]; public int fssz[]=new int[20]; public ButtonTest1(){ super("testing buttons"); Container container=getContentPane(); container.setLayout(new FlowLayout()); aB=new JButton("输入学生姓名和分数"); container.add(aB); //ButtonHandler handler=new ButtonHandler(); bB=new JButton("退出"); container.add(bB); ButtonHandler handler=new ButtonHandler(); aB.addActionListener(handler); bB.addActionListener(handler); setSize(800,256); setVisible(true); } public static void main(String args[]){  ......
本人完成差不多程序(2006-04-01 21:22:00)
摘要:import java.awt.*;import java.awt.event.*;import javax.swing.*;public class ButtonTest1 extends JFrame{ private JButton aB,bB,exitButton,qrButton; private JLabel mz,fs; private JTextField mz1,fs1; public String mzsz[]=new String[20]; public int fssz[]=new int[20]; public ButtonTest1(){ super("testing buttons"); Container container=getContentPane(); container.setLayout(new FlowLayout()); aB=new JButton("输入学生姓名和分数"); container.add(aB); //ButtonHandler handler=new ButtonHandler(); bB=new JButton("退出"); container.add(bB); ButtonHandler handler=new ButtonHandler(); aB.addActionListener(handler); bB.addActionListener(handler); setSize(800,256); setVisible(true); } public static void main(String args[]){ ButtonTes......
本人的JAVA分数输入程序(冒泡)(2006-04-01 21:19:00)
摘要:import javax.swing.JOptionPane;public class FenShu{ public static void main(String args[]){ FenShu aaa=new FenShu(); String n1,n2; int gs,average,sum=0; n1=JOptionPane.showInputDialog("请输入人数:"); gs=Integer.parseInt(n1); int fs[]=new int[gs]; for(int j=0;j<gs;j++) {n2=JOptionPane.showInputDialog("输入第"+(j+1)+"分数"); fs[j]=Integer.parseInt(n2); } //排训 // System.out.print("!!!!!!!!!!!!") ; for(int o = fs.length - 1; o >= 0; o--){ for(int k = 0,temp; k < o; k++) { if(fs[k]>fs[k+1]) { temp=fs[k]; fs[k]=fs[k+1]; fs[k+1]=temp;} } } for(int w=0;w<fs.length;w++){ sum+=fs[w];} average=sum/gs;
//输出 String output="总分数为"+" "+sum+"平均分为 "+average+"排序是:"; for(int w=0;w<fs.length;w++)  ......
学习JAVA的书籍(2006-03-28 14:30:00)
摘要:以前的帖子:
一、入门《Java 2从入门到精通》- 推荐《Thinking in Java》- 强烈推荐*新手可能有点难度O’reilly的Java编程基础系列 - 参考*
二、进阶《Java Cook Book》- 非常推荐* (包含了Java编程的Tips,适合当做手册来查阅)《O’reilly-Java IO》- 推荐* (包含Java IO编程的各个方面)《O’reilly-Database Programming with JDBC》- 推荐* (JDBC编程)《O’reilly-Java Programming with Oracle JDBC》- 参考*
三、Java Web编程《O’reilly-Java Server Pages》- 强烈推荐* 《O’reilly-Java Servlet Programming》- 非常推荐*《O’reilly-Jakarta Struts》- 推荐* (Java Web编程的一个MVC实现框架Struts的书)
四、EJB编程《J2EE应用与BEA Weblogic Server》- 强烈推荐《Mastering EJB 2.0》- 非常推荐* 《Enterprise Java Bean》- 推荐*
五、Java XML编程《O’reilly-Java and XML》- 推荐*《O’reilly-Java and SOAP》- 参考* (Java的SOAP编程)
六、设计模式《Core J2EE Patterns》- 强烈推荐* (J2EE设计模式,设计企业应用软件必备参考书)《EJB Design Patterns》- 推荐*
七、其它《O’reilly Ant - The Definitive Guide》- 推荐* (Ant是一种功能非常强大的Java工具)......
