processing-MySQL example2-getString("StringName")

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()
{
  
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值