troubleshooting Question

java file that will expose two methods

Avatar of STEVE00098
STEVE00098 asked on
JavaJSP
17 Comments1 Solution304 ViewsLast Modified:
I am tring to copile  the below java to a class file. But I get the error message ( all the way down) please help
public class Stringtoarray

{
      public static String[] toarray(String s)
      {
      String[] array =s.split(";");
      return array;
      }

 public static void main(String[] args) {

      // Create a variable for the connection string.
      String connectionUrl = "jdbc:sqlserver://sqlserver:1433;" +
         "databaseName=abm;user=janitorial;password=janitorial";

      // Declare the JDBC objects.
      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;

      try {
         // Establish the connection.
         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
         con = DriverManager.getConnection(connectionUrl);

         // Create and execute an SQL statement that returns some data.
         String SQL = "SELECT TOP 10 * FROM Person.Contact";
         stmt = con.createStatement();
         rs = stmt.executeQuery(SQL);

         // Iterate through the data in the result set and display it.
         while (rs.next()) {
            System.out.println(rs.getString(4) + " " + rs.getString(6));
         }
      }

      // Handle any errors that may have occurred.
      catch (Exception e) {
         e.printStackTrace();
      }
      finally {
         if (rs != null) try { rs.close(); } catch(Exception e) {}
         if (stmt != null) try { stmt.close(); } catch(Exception e) {}
         if (con != null) try { con.close(); } catch(Exception e) {}
      }
   }


      }
Error
Stringtoarray.java:17: cannot find symbol
symbol  : class Connection
location: class Stringtoarray
      Connection con = null;
      ^
Stringtoarray.java:18: cannot find symbol
symbol  : class Statement
location: class Stringtoarray
      Statement stmt = null;
      ^
Stringtoarray.java:19: cannot find symbol
symbol  : class ResultSet
location: class Stringtoarray
      ResultSet rs = null;
      ^
Stringtoarray.java:24: cannot find symbol
symbol  : variable DriverManager
location: class Stringtoarray
         con = DriverManager.getConnection(connectionUrl);
               ^
4 errors
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros