java - Mysql DB connection with JDBC freezing program -


i have mysql jdbc library added eclipse project still cant connect database, program doesn't throw error, freezes on me. here's link library used http://dev.mysql.com/downloads/connector/j , current code ( username, host, , passwords omitted.

  private connection connect = null;   private statement statement = null;   private preparedstatement preparedstatement = null;   private resultset resultset = null;  @override     try {           // load mysql driver, each db has own driver           class.forname("com.mysql.jdbc.driver");           // setup connection db           connect = drivermanager               .getconnection("jdbc:mysql://host:8080/feedback?"                   + "user=******admin&password=********");            // statements allow issue sql queries database           statement = connect.createstatement();           // result set result of sql query           system.out.println("connected");         } catch (exception e) {           system.out.println("connection failed"); 

solution had port wrong, driver installed improperly , database name wrong. here correct connection line after fixing driver.

 connect = drivermanager                   .getconnection("jdbc:mysql://localhost:3306/database?"                       + "user=****admin&password=*******"); 

try connect in format

drivermanager.getconnection("jdbc:mysql://localhost:port","username" , "password"); 

please use latest driver fits mysql version.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -