java報表系統源碼
① java紼嬪簭璁捐★紝澶氭佸湪宸ヨ祫緋葷粺涓鐨勫簲鐢ㄣ傝峰皢銆愪唬鐮佷竴銆戝埌銆愪唬鐮佸叚銆戠敤涓篔ava婧愪唬鐮佸~鍐
浠g爜涓錛
private Double weeklySalary;
浠g爜浜岋細
public void setWeeklySalary(Double weeklySalary){
this.weeklySalary=weeklySalary;
}
浠g爜涓夛細
private Double salary;
private Integer piece;
public PieceWorker (String name,Integer p,Double s) {
super(name);
setSalary(s);
setPiece(p);
}
public void setPiece(Integer p){
this.piece=p;
}
public void setSalary(Double s){
this.salary=s;
}
public double earnings() {
return piece*salary;
}
浠g爜鍥涳細
private Double salary;
private Integer hour;
public PieceWorker (String name,Integer h,Double s) {
super(name);
setSalary(s);
setHour(h);
}
public void setHour(Integer h){
this.hour=h;
}
public void setSalary(Double s){
this.salary=s;
}
public double earnings() {
return h*salary;
}
② 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瀛︾敓鎴愮嘩綆$悊緋葷粺
Java瀛︾敓鎴愮嘩綆$悊緋葷粺婧愪唬鐮侊細
import Java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
/*
* Created on 2005-1-11
*/
/**
* @author 璁╃倻
* @since 1.0
*
* TODO 瀛︾敓鎴愮嘩娌葷悊緋葷粺
* 閫氳繃瀛﹀彿鏌ユ壘,淇鏀,鍒犻櫎鏁版嵁
*
*/
public class LittleProgram
{
static boolean isDelete = true;
static boolean isFind = true;
public static void main(String [] args)//涓繪柟娉,紼嬪簭浠庤繖閲屽紑濮嬭繍琛
throws IOException,NumberNotFoundException
{
int choice=-1;
do{
LittleProgram lp = new LittleProgram();
System.out.println();
System.out.println("\t####################################");
System.out.println();
System.out.println("\t\t Java瀛︾敓鎴愮嘩娌葷悊緋葷粺1.1");
System.out.println("\t\t璇風敤瀛﹀彿鏌ユ壘,淇鏀,鍒犻櫎鏁版嵁");
System.out.println();
System.out.println("\t####################################\n");
System.out.print("1.澧炲姞鏁版嵁:\n"+
"2.鏌ユ壘鏁版嵁:\n"+
"3.鍒犻櫎鏁版嵁:\n"+
"4.娓呴櫎鎵鏈夋暟鎹:\n"+
"5.鎶婃暟鎹鍏ㄩ儴鎵撳嵃鍒板睆騫\n"+
"6.鎶婃垚緇╂寜瀛﹀彿鎺掑簭\n"+
"7.淇鏀規暟鎹\n"+
"8.緇熻″凡璁板綍鎴愮嘩瀛︾敓鏁\n"+
"9.鍏充簬浣滆\n"+
"0.閫鍑虹▼搴.\n" +
"杈撳叆:");
BufferedReader in = //浠庣粓
new BufferedReader( //絝鎺
new InputStreamReader(System.in));//鏀舵暟
String inputLine = in.readLine(); //瀛楅
choice= Integer.valueOf(inputLine).intValue();//欏;
switch(choice)
{
case 1: {//1.澧炲姞鏁版嵁
String str = lp.inputData();
lp.addData(str);
System.out.println("澧炲姞鏁版嵁鎴愬姛.");
timeOut(1);
}break;
case 2: {//2.鏌ユ壘鏁版嵁
long find = 0;
璧勬枡寮曠敤:http://www.knowsky.com/363450.html
④ java如何查看源碼
不會就別那麼肯定的說看不到~
jdk里有個src.zip,解壓以後放在jre里ok
如果不行,在eclipse里建立一個叫jre的文件夾,然後把jre6里的東西考進去,把src考進去,必須行。
⑤ 急求java學生信息管理系統源代碼,帶有連接資料庫的,萬分感謝
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
public class MainFrame extends JFrame implements ActionListener{
InsertPanel ip = null;
SelectPanel sp = null;
JPanel pframe;
JButton jb1,jb2,jb3;
JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42;
CardLayout clayout;
public MainFrame(String s){
super(s);
JMenuBar mb = new JMenuBar();
this.setJMenuBar(mb);
JMenu m1 = new JMenu("系統");
JMenu m2 = new JMenu("基本信息");
JMenu m3 = new JMenu("成績");
JMenu m4 = new JMenu("獎懲");
mb.add(m1);
mb.add(m2);
mb.add(m3);
mb.add(m4);
jm11 = new JMenuItem("退出系統");
jm21 = new JMenuItem("輸入");
jm22 = new JMenuItem("查詢");
jm23 = new JMenuItem("更改");
jm31 = new JMenuItem("輸入成績");
jm32 = new JMenuItem("查詢成績");
jm41 = new JMenuItem("獎勵");
jm42 = new JMenuItem("處分");
m1.add(jm11);
m2.add(jm21);
m2.add(jm22);
m2.add(jm23);
m3.add(jm31);
m3.add(jm32);
m4.add(jm41);
m4.add(jm42);
Icon i1 = new ImageIcon();
Icon i2 = new ImageIcon();
Icon i3 = new ImageIcon();
jb1 = new JButton(i1);
jb1.setToolTipText("輸入");
jb2 = new JButton(i2);
jb2.setToolTipText("查詢");
jb3 = new JButton(i3);
jb3.setToolTipText("退出");
JToolBar tb = new JToolBar("系統工具");
tb.add(jb1);
tb.add(jb2);
tb.add(jb3);
add(tb,BorderLayout.NORTH);
jm11.addActionListener(this);
jm21.addActionListener(this);
jm22.addActionListener(this);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
clayout = new CardLayout();
pframe = new JPanel(clayout);
add(pframe);
JPanel mainp = new JPanel(new BorderLayout());
JLabel mainl = new JLabel("學生信息管理平台",SwingConstants.CENTER);
mainl.setFont(new Font("serif",Font.BOLD,30));
mainp.add(mainl);
pframe.add(mainp,"main");
clayout.show(pframe, "main");
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jm21 || e.getSource() == jb1){
if(ip == null){
ip= new InsertPanel();
pframe.add(ip,"insert");
}
clayout.show(pframe, "insert");
this.setTitle("輸入學生信息");
}
else if(e.getSource() == jm22 || e.getSource() == jb2){
if(sp == null){
sp= new SelectPanel();
pframe.add(sp,"select");
}
clayout.show(pframe, "select");
this.setTitle("查詢學生信息");
}
else if(e.getSource() == jm11 || e.getSource() == jb3){
System.exit(0);
}
}
}
第二個:
import javax.swing.JFrame;
public class MainTest {
public static void main(String [] args){
MainFrame f = new MainFrame("學生信息管理平台");
f.setSize(400,300);
f.setLocation(350,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第二個:
import java.sql.Connection;
import java.sql.DriverManager;
public class MySQLConnection {
static Connection getCon(){
Connection con = null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","123");
}
catch(Exception e){
System.out.println("建立資料庫連接遇到異常!");
}
return con;
}
}
第四個:
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class SelectPanel extends JPanel implements ActionListener{
JButton jb;
JTextField jt;
JTextField jt1,jt2,jt3,jt4;
public SelectPanel(){
JLabel jl = new JLabel("請輸入學號:",SwingConstants.CENTER);
jt = new JTextField();
jb = new JButton("確定");
JPanel jp1 = new JPanel(new GridLayout(1,3));
jp1.add(jl);
jp1.add(jt);
jp1.add(jb);
JLabel j1,j2,j3,j4;
j1 = new JLabel("學號:",SwingConstants.CENTER);
j2 = new JLabel("姓名:",SwingConstants.CENTER);
j3 = new JLabel("性別:",SwingConstants.CENTER);
j4 = new JLabel("年齡:",SwingConstants.CENTER);
jt1 = new JTextField(6);
jt1.setEditable(false);
jt2 = new JTextField(6);
jt2.setEditable(false);
jt3 = new JTextField(6);
jt3.setEditable(false);
jt4 = new JTextField(6);
jt4.setEditable(false);
JPanel jp2 = new JPanel(new BorderLayout());
JPanel jp3 = new JPanel(new GridLayout(4,2));
jp2.add(new JLabel(""),BorderLayout.NORTH);
jp3.add(j1);
jp3.add(jt1);
jp3.add(j2);
jp3.add(jt2);
jp3.add(j3);
jp3.add(jt3);
jp3.add(j4);
jp3.add(jt4);
jp2.add(jp3);
this.setLayout(new BorderLayout());
add(jp1,BorderLayout.NORTH);
add(jp2);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jb){
String stuNo = jt.getText().trim();
Student s = new Student();
boolean b = true;
try{
b = s.selectByStuNo(stuNo);
}
catch(Exception ex){
System.out.println("查詢學生信息遇到異常!");
}
if(b){
jt1.setText(s.getStuNo());
jt2.setText(s.getName());
jt3.setText(s.getGender());
int a = s.getAge();
Integer i = new Integer(a);
jt4.setText(i.toString());
}
else{
JOptionPane.showMessageDialog(null, "無此學生!");
}
}
}
}
第五個:
import javax.swing.JFrame;
public class SelectTest {
public static void main(String [] args){
JFrame f = new JFrame("查詢學生信息");
SelectPanel p = new SelectPanel();
f.add(p);
f.setSize(400,300);
f.setLocation(300,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第六個:
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class Student {
String stuNo;
String name;
String gender;
int age;
public Student(){}
public Student(String stuNo,String name,String gender, int age){
this.stuNo = stuNo;
this.name = name;
this.gender = gender;
this.age = age;
}
public String getStuNo(){
return stuNo;
}
public void setStuNo(String stuNo){
this.stuNo = stuNo;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getGender(){
return gender;
}
public void setGender(String gender){
this.gender = gender;
}
public int getAge(){
return age;
}
public void setAge(int age){
this.age = age;
}
public boolean insertStudent(){
boolean b = true;
try{
Connection con = MySQLConnection.getCon();
Statement statement = con.createStatement();
String sql = "insert into student values('" + stuNo + "','" + name +"','" + gender + "'," + age + ")";
sql = new String(sql.getBytes("gb2312"),"ISO8859_1");
statement.executeUpdate(sql);
con.close();
}
catch(Exception e){
b = false;
System.out.println("插入資料庫遇到異常!");
}
return b;
}
public boolean selectByStuNo(String stuNo)throws Exception{
boolean b = true;
Connection con = MySQLConnection.getCon();
Statement statement = con.createStatement();
String sql = "select * from student where stuNo =" + stuNo;
ResultSet rs = statement.executeQuery(sql);
if(rs != null && rs.next()){
String no = rs.getString(1);
this.setStuNo(no);
String n = rs.getString(2);
n = new String(n.getBytes("ISO8859_1"),"gb2312");
this.setName(n);
String g = rs.getString(3);
g = new String (g.getBytes("ISO8859_1"),"gb2312");
this.setGender(g);
this.setAge(rs.getInt(4));
b = true;
}
rs.close();
statement.close();
con.close();
return b;
}
}
資料庫你自己弄吧,我沒時間弄了!初學得多動手哦
⑥ 下載的java源代碼怎麼打開
.class文件是java編譯後的文件,它不是源代碼,真正的java源代碼是.java文件。
java源代碼是txt格式的.java文件,用記事本就可以打開。
用eclipse打開java文件的方式是:
如果java文件是一個eclipse工程(根目錄帶有.project文件),用file/import/general/exist java project/(大概是)然後找到你的目錄。
否則需要自己新建一個工程file/new/java project
然後把java文件拷貝到.src目錄下。
.class文件是直接的編譯好的文件,可以用jad把.class文件反編譯成java文件,不過反編譯的代碼和原來的代碼不一定完全一樣。
⑦ 用JAVA編程的通過SQL連接資料庫的商品庫存管理系統的源代碼
package com.company.;
import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class BaseDao {
// 資料庫驅動
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//url
String url = "jdbc:sqlserver://資料庫ip:埠號;databaseName=資料庫名;";
//用戶名
String uname = "資料庫用戶名";
//密碼
String pwd = "資料庫密碼";
/**
* 獲得連接對象
* @return
*/
protected Connection getCon(){
//返回的連接
Connection con = null;
try {
//載入驅動
Class.forName(driver);
//得到連接
con = DriverManager.getConnection(url, uname, pwd);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return con;
}
/**
* 關閉資料庫
* @param con
* @param stmt
* @param rs
*/
protected void closeDB(Connection con, Statement stmt, ResultSet rs){
if(rs != null){
try {
//關閉結果集
rs.close();
rs = null;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(stmt != null){
try {
//關閉語句對象
stmt.close();
stmt = null;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(con != null){
try {
//關閉連接對象
con.close();
con = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
protected void closeDB(Connection con, PreparedStatement pstmt, ResultSet rs){
if(rs != null){
//關閉結果集
try {
rs.close();
rs = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
if(pstmt != null){
try {
pstmt.close();
pstmt = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
if(con != null){
try {
con.close();
con = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
這個是我寫的一個基本的連接sql2005資料庫的代碼,.! 不知道你能不能用,! 你看一下吧, 連接的時候需要sqljdbc.jar資料庫驅動,!