Connect Procssing with Database

Hello everyone,
I’ve read that i can normally use java code with processing code in one program.
I created the following class to connect to MYSQL online server “which i created online”

import java.sql.*;
class Database
  {    
    void Database () 
      {        
      }
    void createDatabase ()
      {
        try
          {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection ("jdbc:mysql://remotemysql.com:3306/gPQbxUed4a","gPQbxUed4a","********");
            Statement stmt = con.createStatement();
            stmt.executeQuery("use gPQbxUed4a;");
            stmt.executeQuery("create table emp(id int(10),name varchar(40),age int(3));");
            con.close();
          }
         catch (Exception e)
          {
            System.out.println(e);
          }
      }
  }

in the main sheet i create instance of the database and run createDatabase method

Database myDatabase = new Database();
 myDatabase.createDatabase();

after running the code a table should be created in my database. However, I’m checking the database and nothing is happeneed

Could you provide all the code, including the Processing code? The code you provided defines the class. You need to show the lines where the class is instantiated. I would recommend to work in a local environment before you attempt to connect to a server. It will be easier to debug your code.

You should consider checking the DB Manager tool and see if it works for you: https://forum.processing.org/two/discussion/21440/db-manager-for-processing

Kf

This looks wrong

The constructor is without void

Here is the code

Database myDatabase = new Database();

void setup()
{
  myDatabase.createDatabase();
}

You might be interested in the SQL Library for Processing.

There are also interesting example sketches connected with the DB Manager for Processing (mentioned earlier):

Also see: