https://hourofcode.com/us/learn
processing hour of code
http://hello.processing.org/editor/
2. BezierSQLib
http://bezier.de/processing/libs/sql/
*先將BezierSQLib的檔案(解zip)放到Processing→libraries



//Library by fjenett
//Example created on 2014-03-12 by Powder
//Tested with Processing 3.0a5
import de.bezier.data.sql.*;
String dbHost="localhost";//if you are using a local database,this should be fine
String dbPort="3306";//replace with database port,MAMP standard is 8889
String dbUser="root";//replace with database username,MAMP standard is "root"
String dbPass="";//replace with database password,MAMP standard is "root"
String dbName="ntnu_ice";//replace with database name
String tableName="name";//replace with table name
String result="";
MySQL msql;
void setup(){
size(600,600);
msql=new MySQL( this,dbHost+":"+dbPort,dbName,dbUser,dbPass);
if(msql.connect()){
//get number of rows
msql.query("SELECT COUNT(*) FROM"+tableName);
msql.next();
println("Number of rows:"+msql.getInt(1));
println();
//access table
msql.query("SELECT*FROM"+tableName);
while(msql.next()){
//replace "first_name" and "last_name" with column names from your table
String s1=msql.getString("ID");
String s2=msql.getString("Tele");
println(s1+""+s2);
result=s1;
result+=""+s2;
}
}else{
println("Yikes,there was an error!");
}
}
void draw(){
textSize(50);
text(result,10,100);
}
沒有留言:
張貼留言