Thread: JDBC / MySQL

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    3
    Rep Power
    0

    JDBC / MySQL


    Here is my Java code:
    Code:
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    
    public class MySQL {
    	public static void main(String[] args) {
    
     		// The call to Class.forName explicitly loads the driver class
            Class.forName("org.gjt.mm.mysql.Driver");
            // the following url says that the protocol is jdbc, the 
            // subprotocol is mysql, and our database (thebookdemo) is installed on the machine 
            // anvil
            String url = "jdbc:mysql://dnetv/darrendn";
    
            // the method DriverManager.getConnection is the only method that a 
            // general programmer needs to use directly. This method establishes a 
            // connection to a database specified by a URL, loginID and password.
            Connection con = DriverManager.getConnection(url, "root", "rajanator");
    
            // Once a connection has been established we can create an instance 
            // of Statement, through which we will send queries to the database.
            Statement stmt = con.createStatement();
      
            // The method executeQuery executes a query on the database. The 
            // return result is of type ResultSet which is one or more rows in 
            // this case.
            ResultSet rs = stmt.executeQuery("SELECT name FROM graffiti_wall");
    
    	}
    }
    even with simple code i get lots of errors! when I run it.
    Code:
    Exeption in thread "main" java.lang.Error: Unresolved compilation problem: out cannot be resolved
    
    at sun.reflect.NativeConstructorAccessorImple.newInstance0(Native Method)
    
    at sun.rat sun.reflect.NativeConstructorAccessorImple.newInstance(NativeConstrucotrImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance0(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.COnstructor.inewInstance(Constructor.java:274)
    at MySQL.main(MySQL.java:35)
    Does anyone have any idea what this cryptic error msg means?

    I do PHP and MySQL development, so this java stuff is quite new to me.

    Thanks in advance.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    6
    Rep Power
    0
    the error refer to line 35 of MySql.java. but your source code is less than 35 lines...post more...

IMN logo majestic logo threadwatch logo seochat tools logo