string driver="org.gjt.mm.mysql.Driver";
url="jdbc:mysql://localhost:3306";
Connection conn=null;
Class.forName(driver).newInstance();
conn=DriverManager.getConnection(url,username,password);

解决方案 »

  1.   

    哦,忘记看你的问题了,以为是MYSQL怎么连接。你把你的驱动程序放你目录下的LIB里面。
      

  2.   

    你装一个JDBC的驱动,然后把该驱动中的库文件加入Jbuilder中
      

  3.   

    靠,一个说mssql,一个说mysql,这个还说谢谢我晕!两个都是老花眼!
      

  4.   

    应该是    private String strDbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";

    不是odbd,你打错了啦
    还有要记得在odbc数据源那里设置一下就可以了
      

  5.   

    安装ms sql的jdbc驱动,设置path就可以了
      

  6.   

    to  wantvictory(威科特)     大哥,是classpath还是path啊。
      

  7.   

    MySQL数据库 
    Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
    String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" 
    //myDB为数据库名 
    Connection conn= DriverManager.getConnection(url); 
      

  8.   

    安装SQLServerDriversetup.exe驱动,和上面的的java代码,就可以行的SQLServerDriversetup.exe 自己去搜一下把
      

  9.   

    import java.sql.*;public class jdbctest
    {
        public static void main(String[] args)
        {
            try
            {
                Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                String s = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
                String s1 = "用户名";
                String s2 = "密码";
                Connection connection = DriverManager.getConnection(s, s1, s2);
                Statement statement = connection.createStatement();
                String s3 = "select * from titles";
                ResultSet resultset = statement.executeQuery(s3);
                boolean flag = false;
                for(int i = 0; i < 10; i++)
                {
                    resultset.next();
                    System.out.println(resultset.getString(1));
                }        }
            catch(Exception exception)
            {
                System.out.println(exception.getMessage());
            }
        }
    }