import de.bezier.data.sql.*;
MySQL dbconnection;
void setup()
{
size(100,100);
//database---username---password
String database="mydatas";
String user="hui1570";
String pass="04263028";
//connect to your database
dbconnection=new MySQL(this,"localhost",database,user,pass);
if(dbconnection.connect())
{
//the statement of querying
dbconnection.query("SELECT * FROM user");
while(dbconnection.next()) //next() to get the next row of database
{
//getString("listName") is used to get the list of listName
String i=dbconnection.getString("id");
String u=dbconnection.getString("username");
String p=dbconnection.getString("password");
//we can use 1 to replace "id",use 2 to replace "username" and use 3 to replace "password"
//because 1 represent the first column of user..........
//String i=dbconnection.getString(1);
//String u=dbconnection.getString(2);
//String p=dbconnection.getString(3);
println(i+" "+u+" "+p);
}
}
else
{
println("connection failed!");
}
}
void draw()
{
}
processing-MySQL example2-getString("StringName")
最新推荐文章于 2024-11-01 18:05:04 发布