资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

网上书店java源代码 javaweb网上书城源码

怎样用java web编写网上书店,我就差个购物车,求大师指教,有源代码最好

购物车这个和你登陆差不多啦,点击加入购物车的时候传商品的id,用户的id,商品数量等信息,加入到数据库里就行了

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序制作、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了弋江免费建站欢迎大家使用!

网上书店连接SQL Server 2005的java代码怎么写?

连接数据库的典型步骤

第一步:加载正确的数据库驱动程序

第二步,定义所要连接数据库的地址

String ODBCURL=“jdbc:odbc:dbName”;

String oracleURL= "jdbc:oracle:thin:@host:port:dbName“;

String mysqlURL= "jdbc:mysql:// host:port/dbName“;

String sqlURL=“jdbc:microsoft:sqlserver://host:1433;DatabaseName=dbName”;

第三步,建立与数据库的连接

DriverManager.getConnection(oracleURL,

username,

password);

第四步,创建语句对象

Statement statement = connection.createStatement();

第五步,声明SQL语句,并将该语句通过Statement对象提交给服务器进行执行。

Stringsql= “SELECT * FROM ONTACT_TABLE”;

ResultSet resultSet=statement.executeQuery(sql);

该语句将sql命令提交给数据库服务器进行执行,并将执行结果存储在ResultSet对象中进行执行。

Statement接口主要有如下三个方法:

1. ResultSet executeQuery(String sql)

用于执行查询语句,返回 ResultSet结果集(一个二维表)

2. int executeUpdate(String sql)

用于执行添加、删除或修改操作,返回被更新记录的条数

3. boolean execute(String sql)

执行参数部分的SQL语句;

当SQL语句的执行结果是一个ResultSet结果集时,本方法返回true;并可以通过StatementgetResultSet()方法得到返回的结果集

当SQL语句执行后没有返回的结果集时,该方法返回false

第六步:对查询结果进行分析

while(resultSet.next()){

name =resultSet.getString(1);

phone =resultSet.getString(2);

System.out.println(name+","+phone);

}

第七步,关闭打开的资源

resultSet.close();

statement.close();

connection.close();

将打开的资源关闭。

注意:资源关闭的顺序和打开的顺序恰恰相反。

JSP网上书店(myeclipse,含完整代码。最好是整个网站文件夹)

JSP网上书店这个题目不难,但是JSP基本没有免费的现成的资源可用。JSP源码+Word论文+PPT答辩全套。

java图书管理界面系统的源代码

java swing 登陆界面code

/*

* Login.java

*

* Created on __DATE__, __TIME__

*/

package com.agen.library.window;

import java.awt.Image;

import java.awt.Toolkit;

import javax.swing.JOptionPane;

import javax.swing.UIManager;

import javax.swing.UnsupportedLookAndFeelException;

import com.agen.library.factory.DAOFactory;

import com.agen.library.util.GlobalUser;

import com.agen.library.vo.User;

/**

*

* @author __USER__

*/

public class Login extends javax.swing.JFrame {

/**

*

*/

private static final long serialVersionUID = -2176093732040600809L;

/** Creates new form Login */

public Login() {

super("易云图书管理软件V1.0");

Image ime = Toolkit.getDefaultToolkit().getImage(

getClass().getResource("/images/ico.png"));

try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (InstantiationException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IllegalAccessException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (UnsupportedLookAndFeelException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

setIconImage(ime);

initComponents();

setLocationRelativeTo(null);

this.setResizable(false);

}

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

// GEN-BEGIN:initComponents

// editor-fold defaultstate="collapsed" desc="Generated Code"

private void initComponents() {

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jPasswordField1 = new javax.swing.JPasswordField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jMenuItem1 = new javax.swing.JMenuItem();

jMenu2 = new javax.swing.JMenu();

jMenuItem2 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

addKeyListener(new java.awt.event.KeyAdapter() {

public void keyPressed(java.awt.event.KeyEvent evt) {

formKeyPressed(evt);

}

public void keyTyped(java.awt.event.KeyEvent evt) {

formKeyTyped(evt);

}

});

jLabel2.setFont(new java.awt.Font("微软雅黑", 0, 14));

jLabel2.setText("\u7528\u6237\u540d\uff1a");

jLabel3.setFont(new java.awt.Font("微软雅黑", 0, 14));

jLabel3.setText("\u5bc6 \u7801\uff1a");

jTextField1.setFont(new java.awt.Font("微软雅黑", 0, 14));

jTextField1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jTextField1ActionPerformed(evt);

}

});

jPasswordField1.setFont(new java.awt.Font("微软雅黑", 0, 12));

jPasswordField1.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyTyped(java.awt.event.KeyEvent evt) {

jPasswordField1KeyTyped(evt);

}

});

jButton1.setBackground(new java.awt.Color(223, 216, 216));

jButton1.setFont(new java.awt.Font("微软雅黑", 0, 14));

jButton1.setText("\u767b\u9646");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

jButton2.setBackground(new java.awt.Color(223, 216, 216));

jButton2.setFont(new java.awt.Font("微软雅黑", 0, 14));

jButton2.setText("\u53d6\u6d88");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}

});

jLabel1.setIcon(new javax.swing.ImageIcon(

getClass().getResource("/images/login_main.jpg"))); // NOI18N

jMenu1.setText("File");

jMenu1.setFont(new java.awt.Font("微软雅黑", 0, 14));

jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(

java.awt.event.KeyEvent.VK_Q,

java.awt.event.InputEvent.CTRL_MASK));

jMenuItem1.setText("Exit");

jMenuItem1.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jMenuItem1MouseClicked(evt);

}

});

jMenuItem1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem1ActionPerformed(evt);

}

});

jMenu1.add(jMenuItem1);

jMenuBar1.add(jMenu1);

jMenu2.setText("Help");

jMenu2.setFont(new java.awt.Font("微软雅黑", 0, 14));

jMenuItem2.setText("About");

jMenuItem2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem2ActionPerformed(evt);

}

});

jMenu2.add(jMenuItem2);

jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(

getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout

.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel1)

.addGroup(

layout.createSequentialGroup()

.addContainerGap()

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.TRAILING,

false)

.addComponent(

jLabel2,

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

javax.swing.GroupLayout.Alignment.LEADING,

layout.createSequentialGroup()

.addComponent(

jLabel3)

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

layout.createSequentialGroup()

.addGap(10,

10,

10)

.addComponent(

jButton1)

.addGap(47,

47,

47)

.addComponent(

jButton2))

.addComponent(

jPasswordField1)

.addComponent(

jTextField1,

javax.swing.GroupLayout.DEFAULT_SIZE,

197,

Short.MAX_VALUE))

.addContainerGap()))));

layout.setVerticalGroup(layout

.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

layout.createSequentialGroup()

.addComponent(jLabel1)

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2)

.addComponent(

jTextField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

24,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(

jPasswordField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

23,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1)

.addComponent(jButton2))

.addContainerGap(

javax.swing.GroupLayout.DEFAULT_SIZE,

Short.MAX_VALUE)));

pack();

}// /editor-fold

// GEN-END:initComponents

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

About.start();

}

private void jPasswordField1KeyTyped(java.awt.event.KeyEvent evt) {

if (evt.getKeyChar() == '\n') {

String name = jTextField1.getText(); // 获取用户名

String pass = String.valueOf(jPasswordField1.getPassword());// 获取密码

User user = null;

// 未输入用户名

if (name.equals("") || name == null) {

JOptionPane.showMessageDialog(this, "用户名不允许为空!", "cuowu", 0);

return;

}

try {

user = DAOFactory.getIUserDAOInstance().findById(name);

if (user != null) {

if (user.getPass() != null user.getPass().equals(pass)) {

GlobalUser.LOGIN_USER = user; // 记录当前用户

// 进入主界面

Main.start();

this.dispose();

} else {

JOptionPane.showMessageDialog(this, "用户名或密码错误!");

return;

}

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if (user == null) {

JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);

return;

}

}

}

private void formKeyTyped(java.awt.event.KeyEvent evt) {

}

private void formKeyPressed(java.awt.event.KeyEvent evt) {

}

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

jTextField1.setText("");

jPasswordField1.setText("");

jTextField1.requestFocus();

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

String name = jTextField1.getText(); // 获取用户名

String pass = String.valueOf(jPasswordField1.getPassword());// 获取密码

User user = null;

// 未输入用户名

if (name.equals("")) {

JOptionPane.showMessageDialog(this, "用户名不允许为空!");

return;

}

try {

user = DAOFactory.getIUserDAOInstance().findById(name);

if (user != null) {

if (user.getPass() != null user.getPass().equals(pass)) {

GlobalUser.LOGIN_USER = user; // 记录当前用户

// 进入主界面

Main.start();

this.dispose();

} else {

JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);

return;

}

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if (user == null) {

JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);

return;

}

}

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {

if (JOptionPane.showConfirmDialog(this, "你确定要退出吗?", "提示",

JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

System.exit(0);

}

}

private void jMenuItem1MouseClicked(java.awt.event.MouseEvent evt) {

System.exit(1);

}

/**

* @param args

* the command line arguments

*/

public static void main(String args[]) {

// System.out.println(Login.class.getResource("src/images/images/login_main.jpg"));

// new javax.swing.ImageIcon(

// Login.class.getResource("../../../../images/login_main.jpg"));

// new Login().setVisible(true);

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Login().setVisible(true);

}

});

}

// GEN-BEGIN:variables

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JMenu jMenu1;

private javax.swing.JMenu jMenu2;

private javax.swing.JMenuBar jMenuBar1;

private javax.swing.JMenuItem jMenuItem1;

private javax.swing.JMenuItem jMenuItem2;

private javax.swing.JPasswordField jPasswordField1;

private javax.swing.JTextField jTextField1;

// End of variables declaration//GEN-END:variables

}


当前题目:网上书店java源代码 javaweb网上书城源码
当前URL:http://cdkjz.cn/article/ddgphhd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220