« Return to Thread: werid problem, please help, thanks very much!!!

Re: werid problem, please help, thanks very much!!!

by raybristol :: Rate this Message:

Reply to Author | View in Thread

my whole method is :


private static final String driver = "com.mysql.jdbc.Driver";
            private static final String dbName="Umbrella";
            private static final String connectionURL = "jdbc:mysql://localhost:3306/" + dbName;
           
            Connection conn = null;
           
            public Connection getConnection()
            {
            //   Beginning of JDBC code sections  
                //   ## LOAD DRIVER SECTION ##
                try        {
                    Class.forName(driver);
                    System.out.println(driver + " loaded. ");
                } catch(java.lang.ClassNotFoundException e)     {
                    System.err.print("ClassNotFoundException: ");
                    System.err.println(e.getMessage());
                    System.out.println("\n    >>> Please check your CLASSPATH variable   <<<\n");
                }
               
              //  Beginning of Primary DB access section
                //   ## BOOT DATABASE SECTION ##
               try {
            conn = DriverManager.getConnection(connectionURL, "root", "raymoney");
            System.out.println("URL: " + connectionURL);
                System.out.println("Connection: " + conn);

            //  Beginning of the primary catch block: uses errorPrint method
                 }  catch (Throwable e)  {  
                    /*       Catch all exceptions and pass them to
                    **       the exception reporting method             */
                    System.out.println(" . . . . . .exception thrown:");
                    errorPrint(e);
                 }
                 System.out.println("Getting Started With MySql JDBC program ending.");
                 
                 return conn;
            }

 « Return to Thread: werid problem, please help, thanks very much!!!