Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungJay2021 committed Sep 13, 2017
0 parents commit e7d7ff0
Show file tree
Hide file tree
Showing 505 changed files with 26,539 additions and 0 deletions.
Empty file added .metadata/.lock
Empty file.
1,986 changes: 1,986 additions & 0 deletions .metadata/.log

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Beans>
<Bean Class="com.genuitec.eclipse.sqlexplorer.utils.ConnectionProfile">
<activate>false</activate>
<driverIdentifier Class="net.sourceforge.squirrel_sql.fw.id.UidIdentifier">
<string>151978a:15dc61dd57b:-7fde</string>
</driverIdentifier>
<identifier Class="net.sourceforge.squirrel_sql.fw.id.UidIdentifier">
<string>151978a:15dc61dd57b:-7fdd</string>
</identifier>
<name>MyEclipse Derby</name>
<password encryption="true">gFOjO/OmrJ8m4/rtM2cMIw==</password>
<promptForPassword>false</promptForPassword>
<schema Indexed="true"/>
<schemaDisplayPolicy>0</schemaDisplayPolicy>
<url>jdbc:derby://localhost:1527/myeclipse</url>
<userName>classiccars</userName>
</Bean>
</Beans>
356 changes: 356 additions & 0 deletions .metadata/.plugins/com.genuitec.eclipse.sqlexplorer/SQLDrivers.xml

Large diffs are not rendered by default.

Empty file.
3 changes: 3 additions & 0 deletions .metadata/.plugins/org.eclipse.ant.ui/dialog_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package com.etc._06DeleteDemo;

import java.awt.EventQueue;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import com.etc._03Login.dao.UserDao;
import com.etc._03Login.entity.User;
import javax.swing.JPopupMenu;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class DeleteDemo {

private JFrame frame;
private JTable table;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DeleteDemo window = new DeleteDemo();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public DeleteDemo() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);

JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(70, 54, 297, 145);
frame.getContentPane().add(scrollPane);

table = new JTable();
//����UserDao ���ݿ�
UserDao dao = new UserDao();
Object[][] data = null;//����data����
try {
List<User> list = dao.queryAllUser();
data = new Object[list.size()][4];
for(int i = 0;i<list.size();i++){
User user = list.get(i);
data[i][0] = user.getId();
data[i][1] = user.getUsername();
data[i][2] = user.getSex();
data[i][3] = user.getHobby();
}

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
table.setModel(new DefaultTableModel(
data,
new String[] {
"���", "����", "�Ա�", "����"
}
));
scrollPane.setViewportView(table);

JPopupMenu popupMenu = new JPopupMenu();
addPopup(table, popupMenu);

JMenuItem menuItem_1 = new JMenuItem("ɾ��");
menuItem_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// --------------ɾ�����¼�
System.out.println("ɾ��");
int n = JOptionPane.showConfirmDialog(null, "�Ƿ�ɾ��", "��ʾ",
JOptionPane.YES_NO_OPTION);
System.out.println("n = " + n);

if (n == 0) {// ȷ��ɾ��
// getValueAt(int row, int column)
// ���� row �� column λ�õĵ�Ԫ��ֵ��

Object obj = table.getValueAt(table.getSelectedRow(), 0);
System.out.println(obj);

// ����UserDao ���ݿ�
UserDao dao = new UserDao();
try {
boolean flag = dao.deleteUser((Long) obj);
if (flag) {
JOptionPane.showMessageDialog(null, "ɾ���ɹ�");

//---------���ݿ� tableˢ�����ݿ�ʼ--------------
// ����UserDao ���ݿ�
Object[][] data = null;// ����data����
try {
List<User> list = dao.queryAllUser();
data = new Object[list.size()][4];
for (int i = 0; i < list.size(); i++) {
User user = list.get(i);
data[i][0] = user.getId();
data[i][1] = user.getUsername();
data[i][2] = user.getSex();
data[i][3] = user.getHobby();
}

} catch (Exception e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
table.setModel(new DefaultTableModel(data,
new String[] { "���", "����", "�Ա�", "����" }));

//---------���ݿ� tableˢ�����ݽ���--------------
} else {
JOptionPane.showMessageDialog(null, "ɾ��ʧ��");
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

}

}

});
popupMenu.add(menuItem_1);

JMenu menu = new JMenu("����");
popupMenu.add(menu);

JMenuItem menuItem = new JMenuItem("�����Ӳ˵�");
menu.add(menuItem);
}
private static void addPopup(Component component, final JPopupMenu popup) {
component.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
showMenu(e);
}
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
showMenu(e);
}
}
private void showMenu(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
});
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.etc._02LoginStrDemo;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
* �����
* @author Administrator
*
*/
public class LoginServer {
public static void main(String[] args) throws IOException {
System.out.println("�����׼������.....");
// 1. ������������Socket��ָ���˿ڲ���ʼ����
ServerSocket server = new ServerSocket(8888);
// 2. ʹ��accept()���������ȴ�����������µ�����
Socket client = server.accept();
System.out.println("���ӹ����Ŀͻ���:"+client.getInetAddress());
// 3. ��������������
// 4. �����е�Э���ϲ����Ự
// 5. ʹ��close()�ر�����Socket

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.etc._12singleInstance;

public class Apple {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.etc._01InetAddressDemo;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
* IP����
* @author Administrator
*
*/
public class InetAddressDemo {
public static void main(String[] args) throws IOException {
InetAddress ip = InetAddress.getByName("MNBAUV1MW3IICTF");
// InetAddress ip = InetAddress.getByName("www.baidu.com");
System.out.println(ip);

//��ȡ��������
System.out.println(ip.getHostName());

//��ȡIP��ַ
System.out.println(ip.getHostAddress());


//boolean isReachable(int timeout) �����Ƿ���Դﵽ�õ�ַ��
System.out.println(ip.isReachable(5000));

System.out.println(InetAddress.getLocalHost());



}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.etc._09Task;

class MyThread extends Thread{
private long time;
MyThread(long time){
this.time = time;
}

@Override
public void run() {
// TODO Auto-generated method stub
System.out.println(Thread.currentThread().getName()+" begin...");
try {
Thread.sleep(this.time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName()+" end...");
}
}

public class Task {
//2�� �����⣺���̣߳������̶߳���ÿ��һ��ʱ����ִ���̶߳���1��5�룩��
// �̶߳���2��7�룩���̶߳���3��9�룩
public static void main(String[] args) {
MyThread my1 = new MyThread(5000);
MyThread my2 = new MyThread(7000);
MyThread my3 = new MyThread(9000);
my1.start();
try {
my1.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
my2.start();
try {
my2.join();//ֻ��my2��ִ�� �����߳�Ҫ��
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
my3.start();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.etc._03Login.dao;


import java.sql.SQLException;
import java.util.ArrayList;

import com.etc._03Login.entity.User;
import com.etc._03Login.utils.JDBCUtils;



public class UserDao {
//创建一个JDBC工具对象
private JDBCUtils jdbc = new JDBCUtils();
public UserDao(){
jdbc.getConnection();
}

//插入数据
public boolean addUser(User user) throws Exception{

String sql = "INSERT INTO t_User (id,username,password,sex,birthday,hobby)" +
" VALUES(null,?,?,?,?,?)";
ArrayList<Object> params = new ArrayList<Object>();
params.add(user.getUsername());
params.add(user.getPassword());
params.add(user.getSex());
params.add(user.getBirthday());
params.add(user.getHobby());
boolean flag = jdbc.updateByPreparedStatement(sql, params);
jdbc.releaseConn();
return flag;
}

}
Loading

0 comments on commit e7d7ff0

Please sign in to comment.