📄 showlistbean.java
字号:
package userpicture;
import java.sql.*;
import java.io.*;
import java.util.*;
public class showlistBean {
String fname[] = new String[1000];
String id;
String time[] = new String[1000];
static long total = 0;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public void getPicture(String myid,String direction)
{
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='"+direction+"'";
System.out.println(sql);
ResultSet r = s.executeQuery(sql);
int k = 0;
while(r.next())
{
fname[k] = r.getString(2);
time[k] = r.getString(5);
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;
}
public String gettime(long index)
{
if(index < 0)
index = 0;
if(index > fname.length)
index = fname.length - 1;
System.out.println(fname[(int)index]);
return time[(int)index];
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -