mysqltest.java

来自「用jsp编写的网上投票系统」· Java 代码 · 共 87 行

JAVA
87
字号
package votebean;
import java.sql.*;
import java.util.*;;
public class MysqlTest {

	/**
	 * @param args
	 * @throws ClassNotFoundException 
	 */
	/***
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		// TODO Auto-generated method stub
		String url = "jdbc:mysql://localhost:3306/xiaoq"; 
		 Class.forName("com.mysql.jdbc.Driver");
		String userName = "root"; 
		String password = "304092";
		Connection connection=null;
		Statement stat=null;
		int rs=1;
		try{
			Connection Connection = DriverManager.getConnection(url,userName,password);
			String sql="DELETE FROM vote_admin WHERE Username='"+"xiao"+"'and userpwd='"+"xiaoq1"+"'";
			stat=Connection.createStatement();
			rs=stat.executeUpdate(sql);
			System.out.print(rs);
			/*
			if(rs.next()){
				System.out.print(rs.getString("userpwd"));
			}
			*/
	/***
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try{
				/*
				if(rs!=null){
					rs.close();
				}
				*/
	/**
				if(stat!=null){
					stat.close();
				}
				if(connection!=null){
					connection.close();
				}
			}catch(SQLException sq){
				sq.getStackTrace();
			}
		}
	}
*/
	/**测试插入
	public static void main(String[] args){
		String title="do you like jsp?";
		String stile="new";
		String starTime="2006-1-24";
		String endTime="2007-3-30";
		int active=2;
		Questions q=new Questions();
		q.setActive(active);
		q.setStrStartime(starTime);
		q.setStrEndtime(endTime);
		q.setStyle(stile);
		q.setTitle(title);
		Collection items=new ArrayList();
		Item item=null;
		for(int i=1;i<=5;i++){
			item=new Item();
			item.setOptions("i");
			items.add(item);
			item=null;
		}
		VoteMgr mgr=new VoteMgr();
		q.setItem(items);
		int i=mgr.addVote(q);
		if(i==1){
			System.out.print("OK");
		}else{
			System.out.print(i);
			System.out.print("no way");
		}
	}
	*/
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?