This is my code..Just starting with mySQL. IDE is netbeans 7.2.1
package monitordata;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.xml.ws.Endpoint;
public class monitorDataMF {
public static void main(String[] args){
Statement stmt = null;
String dbname = null;
String dbuser = null;
String dbpass = null;
String dbport = null;
String dbIP = null;
//pairnoume tis parametrous gia ti sindesi me ti vasi apo to properties file
try{
Properties prop = new Properties();
prop.load(new FileInputStream("mySQL.properties"));
dbname = prop.getProperty("dbname");
dbuser = prop.getProperty("dbuser");
dbpass = prop.getProperty("dbpass");
dbport = prop.getProperty("dbport");
dbIP = prop.getProperty("dbIP");
}catch(IOException e){e.printStackTrace();}
//connecting with database
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver");
String dbUrl = "jdbc:mysql://" + dbIP + ":" + dbport + "/" + dbname;
conn = DriverManager.getConnection(dbUrl, dbuser, dbpass);
String createTable = "CREATE TABLE IF NOT EXISTS test"
+ "(NAME VARCHAR(40) NOT NULL)";
//String insertData = "INSERT INTO test "
// + "VALUES ('Stelios','Thwmas')";
stmt = conn.createStatement();
stmt.executeUpdate(createTable);
//stmt.executeUpdate(insertData);
}catch(ClassNotFoundException | SQLException e){}
}
}
I execute the update, i go to Services>WebInterfaces i hit refresh and the table isn't there. I am not sure if i should executeUpdate or executeQuery
Update: This is the actual error Caught exception: Access denied for user 'root '@'localhost' (using password: YES) but i printed the pass that i sent to the connection statement and it corresponds with the pass needed for the database to start. Not sure what i am doing wrong