netbeans single java file not running -


i trying fetch data db. below code trying run reason when try run file, netbeans notification says application deployed still file not running. think missing silly thing cant figure out.. need help!

class getdbdata {  private final string jdbc_driver = "com.mysql.jdbc.driver"; private final string db_url = "jdbc:mysql://localhost:3306/test"; private final string user = "root"; private final string pass = ""; connection conn; statement stmt; resultset rs;  public void getdbdata() throws sqlexception, classnotfoundexception {     class.forname("com.mysql.jdbc.driver");      conn = drivermanager.getconnection(db_url, user, pass);     stmt = conn.createstatement();  }  public string[] getavailablemeasuremu() throws sqlexception {     string sql;     sql = "select * availablemeasures incentive=mu";     rs = stmt.executequery(sql);     string x = null;     vector data = new vector();     while (rs.next()) {          data.add(rs.getstring("measure"));     }     (object data1 : data) {         system.out.println(data1);     }      return null;  }  public static void main(string[] args) {     system.out.println("called");     getdbdata call = new getdbdata();     try {         call.getavailablemeasuremu();     } catch (exception e) {         system.out.println(e);     } } 

}

edit : ran simple code still netbeans nothing..

class test {  public static void main(string[] args) {      system.out.println("test"); } 

}

edit - ran above code in netbeans 8.0.2 did not run. used same code in 7.2 version , runs.

try code works netbeans 8.0.2.
1 : in package there should public class. made class public in code.
2 : constructor not have return type not void. in code void.

public class getdbdata {  private final string jdbc_driver = "com.mysql.jdbc.driver";    private final string db_url = "jdbc:mysql://localhost:3306/test";    private final string user = "root";    private final string pass = "";        connection conn;        statement stmt;        resultset rs;     public getdbdata() throws sqlexception, classnotfoundexception {    class.forname("com.mysql.jdbc.driver");        conn = drivermanager.getconnection(db_url, user, pass);        stmt = conn.createstatement();    }  public string[] getavailablemeasuremu() throws sqlexception {        string sql;        sql = "select * availablemeasures incentive='"+"mu"+"'";        rs = stmt.executequery(sql);         string x = null;         vector data = new vector();         while (rs.next()) {              data.add(rs.getstring("measure"));         }         (object data1 : data) {             system.out.println(data1);         }          return null;      }  public static void main(string[] args){         system.out.println("called");           getdbdata call = null;         try {             call = new getdbdata();         } catch (sqlexception ex) {              logger.getlogger(getdbdata.class.getname()).log(level.severe, null, ex);          } catch (classnotfoundexception ex) {              logger.getlogger(getdbdata.class.getname()).log(level.severe, null, ex);         }          try {             call.getavailablemeasuremu();          } catch (exception e) {              system.out.println(e);          }      } } 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -