求各路大神们帮帮小弟,数据库连接除了问题

package jk.action;

/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor. */

/**
*

  • @author Administrator
    /
    import java.sql.
    ;
    public class link {
    String userName="root";
    //密码
    String userPasswd="123456";
    //数据库名
    String dbName="tushuguanli";

    Connection con;
    public Statement st;
    public ResultSet rs;

    public link(){////用来链接mysql数据库的类,其他Action类可以调用它来完成对数据库的操作
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    //String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
    String url="jdbc:mysql://localhost:3306/dbName?user=root&password=userPasswd";
    Connection con=DriverManager.getConnection(url);
    Statement st=con.createStatement();

    }

    catch(java.lang.Exception e)
    { 
        System.out.println("Link DB error "+e.getMessage());        
    }
    

    }

}

先把链接字符串打印出来,然后看你拼接对了没?估计字符串组合不对。

设置断点调试看看问题出在哪里

Connection con;
public Statement st; 为什么多次申明~?