Question about SQLibrary?
              in 
             Contributed Library Questions 
              •  
              2 years ago    
            
 
           
             Hi there,
            
            
            
i'm trying to re-use and old sketch i used two years ago, but it's seems that's the SQlibrary has changed, "the constructor" is not working the same way that did before, when i try to create an instance:
msql = new MySQL( Hostname+":"+Port, Database, Username, Password, this.parent );
            
the library tells me that's is undefined.
      
            
Can someone help me please?
            
thanks!
            
            
here is my class:
            
            
 
            
           i'm trying to re-use and old sketch i used two years ago, but it's seems that's the SQlibrary has changed, "the constructor" is not working the same way that did before, when i try to create an instance:
msql = new MySQL( Hostname+":"+Port, Database, Username, Password, this.parent );
the library tells me that's is undefined.
Can someone help me please?
thanks!
here is my class:
- // ---------------------------------------------------------
 // class SMSManager
 //
 // grabs messages from a database
 // ---------------------------------------------------------
 class SMSManager implements Runnable
 {
 // Applet parent
 PApplet parent;
 // SQL
 MySQL msql;
 // Thread
 Thread grabThread;
 int wait;
 // Last Id
 String lastMessageIdFile="lastSessionMessageId.txt";
 int lastMessageId;
 SMSManager(PApplet parent, int wait)
 {
 this.parent = parent;
 this.wait = wait * 1000;
 this.lastMessageId = -1;
 }
 void start()
 {
 try
 {
 String lines[] = loadStrings(lastMessageIdFile);
 if (lines.length>0)
 this.lastMessageId = int(lines[0]);
 }
 catch(Exception e){
 }
- ///////THE PROBLEM WITH THE CONSTRUCTOR//////
 msql = new MySQL( Hostname+":"+Port, Database, Username, Password, this.parent );
 grabThread = new Thread(this);
 grabThread.start();
 }
 void run()
 {
 if (Thread.currentThread() == this.grabThread)
 {
 while(true)
 {
 if ( msql.connect() )
 {
 // ======== SMS ========
 String sql = "SELECT * FROM smsin WHERE id > "+this.lastMessageId+" ORDER BY id DESC";
 msql.query( sql );
 boolean saveId = false;
 while (msql.next())
 {
 int id = msql.getInt("id");
 if (id != this.lastMessageId)
 {
 saveId = true;
 // Same id
 this.lastMessageId = id;
 // grab infos
 String text = msql.getString("message");
 String phone = msql.getString("sender");
 String timestamp = msql.getString("timestmp");
 // Applet event (in main)
 newMessage( id, text, phone, timestamp);
 }
 }
 msql.close();
 
 // Save last id in a file for the next session
 if (saveId)
 {
 String lines[] = {""+this.lastMessageId};
 saveStrings(lastMessageIdFile, lines);
 }
 }
 try
 {
 this.grabThread.sleep((long)wait);
 }
 catch (Exception e) {
 }
 }
 }
 }
 public void newMessage(int id, String text, String phone, String timestamp)
 {
 println("+ found new message, text="+text+",phone="+phone);
 }
 }
 
              
              1  
            
 
            
 
 
          