Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 4th, 2002, 10:33 AM
IrinaIonela IrinaIonela is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Lisbon
Posts: 45 IrinaIonela User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Arrow Java compile error-don't know how to extend class

I'm trying to extend a class that implements an interface:
: public class relationset extends org.gjt.mm.mysql.Driver

class: org.gjt.mm.mysql.Driver
interface: java.sql.Driver

with the following Java code:
PHP Code:
 import java.sql.*;
 
import java.io.*;

public class 
relationset extends org.gjt.mm.mysql.Driver
{
    public static 
ResultSet execQuery() throws SQLException
    
{
        try
        {
            
Connection databaseConnection DriverManager.getConnection("jdbc:mysql://172.16.4.39:3306/ssntvjp""root""");

            
String sqlString "SELECT * FROM Descriptor D WHERE D.SubDescriptor IS NULL";

            
Statement stmt databaseConnection.createStatement();

            return 
stmt.executeQuery(sqlString);
        }
        catch(
SQLException e)
        {
            throw(
e);
        }
    }



....but the following error occurs:

.\relationset.java:7: unreported exception java.sql.SQLException; must be caught or declared to be thrown

Can anybody tell-me what is wrong with this approah?

Where's
wally ?

Irina/Lisbon/Portugal

Reply With Quote
  #2  
Old March 13th, 2002, 11:00 PM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: the master control
Posts: 264 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 14 m 57 sec
Reputation Power: 13
you need to have more try blocks, and you tried to execute the query when it should be in a try block. i would use a ResultSet interface to get the results of your statement as well...might as well use the java.sql package plus there are a few other things that are wrong. anyway, this should clear up your troubles. also, i would suggest moving the connection attempt to a constructor somewhere. keep the java questions coming...

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection databaseConnection = DriverManager.getConnection("jdbc:mysql://172.16.4.39:3306/ssntvjp", "root", "");
}
catch(ClassNotFoundException cnfex){
System.err.println("Failed to load JDBC/ODBC driver.");
cnfex.printStackTrace();
System.exit(1);
}
catch(SQLException sqlex){
System.err.println("Unable to connect!");
sqlex.printStackTrace();
}
try{
String sqlString = "SELECT * FROM Descriptor D WHERE D.SubDescriptor IS NULL";
ResultSet yourResults;

Statement stmt = databaseConnection.createStatement();
yourResults = stmt.executeQuery(sqlString);
}
catch(SQLException e){
throw(e);
}
//something should be returned here

Reply With Quote
  #3  
Old March 28th, 2002, 03:40 AM
aabha aabha is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: India
Posts: 7 aabha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to aabha
this error doesnt match ur code...it seems like u r runnin class file from the cache...try deleting and re-executing...

Reply With Quote
  #4  
Old March 28th, 2002, 09:39 AM
tron's Avatar
tron tron is offline
SwollenMember
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: the master control
Posts: 264 tron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 14 m 57 sec
Reputation Power: 13
no...actually it does match the fact that you do not have try blocks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Java compile error-don't know how to extend class

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap