⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showbean.java

📁 j2ee做的电子相册网站
💻 JAVA
字号:
package userpicture;


import java.sql.*;
import java.io.*;
import java.util.*;


public class showBean {
	String fname[] = new String[1000];
	String id;
	static long total = 0;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	public void getPicture(String myid)
	{
		try {
				total = 0;
				Class.forName("com.mysql.jdbc.Driver");
				Connection c = DriverManager
						.getConnection("jdbc:mysql://localhost/myphone?user=root&password=123456"); // 连接mysql数据库
				Statement s = c.createStatement();
	
				String sql="select * from picture where ID='"+myid+"' and dirname='"+myid+"'"; 
				System.out.println(sql);
				ResultSet r = s.executeQuery(sql);
				int k = 0;
				while(r.next())
				{
					fname[k] = r.getString(2);
					k++;
					total++;
				}
				s.close();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public String getIndex(long index)
	{
		if(index < 0)
			index = 0;
		if(index > fname.length)
			index = fname.length - 1;
		System.out.println(fname[(int)index]);
		
		return fname[(int)index];
		
	}
	public long getnext(long num)
	{
		System.out.println("total: " +total);
		if(num < 0)
			return 0;
		if(num >= total-1)
			return total-1;
		return num+1;
	}
	
	public long getprivous(long num)
	{
		if(num <=0)
			return 0;
		return num-1;
	}
	
	public long getTotal()
	{
		return total;
	}

}

⌨️ 快捷键说明

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