dangerous import java.sql._

View: New views
9 Messages — Rating Filter:   Alert me  

dangerous import java.sql._

by turicum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everybody!

Yet another simple and mysterious problem: with the "import" statement, running the code will generate a "Exception in thread "main" java.lang.NoSuchMethodError: main". Removing the "import" solves the problem. What am I missing? Changing the name of the object does not modify the outcome. Thanks!

import java.sql._ // remove this line to get rid of the error msg

object Sqltest {
        def main(args: Array[String]) {
          print("OK")
        }
}


Re: dangerous import java.sql._

by Tony Morris-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I shan't spoil it for you, but I shall give ye a hint.

When one alters Array for the word scala.Array then all is well.

turicum wrote:

> Hi everybody!
>
> Yet another simple and mysterious problem: with the "import" statement,
> running the code will generate a "Exception in thread "main"
> java.lang.NoSuchMethodError: main". Removing the "import" solves the
> problem. What am I missing? Changing the name of the object does not modify
> the outcome. Thanks!
>
> import java.sql._ // remove this line to get rid of the error msg
>
> object Sqltest {
> def main(args: Array[String]) {
>  print("OK")
> }
> }
>
>
>  

--
Tony Morris
http://tmorris.net/



Re: dangerous import java.sql._

by turicum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

thank you for the prompt reply!
everything's fine now :)
Alex

Tony Morris-4 wrote:
I shan't spoil it for you, but I shall give ye a hint.

When one alters Array for the word scala.Array then all is well.

turicum wrote:
> Hi everybody!
>
> Yet another simple and mysterious problem: with the "import" statement,
> running the code will generate a "Exception in thread "main"
> java.lang.NoSuchMethodError: main". Removing the "import" solves the
> problem. What am I missing? Changing the name of the object does not modify
> the outcome. Thanks!
>
> import java.sql._ // remove this line to get rid of the error msg
>
> object Sqltest {
> def main(args: Array[String]) {
>  print("OK")
> }
> }
>
>
>  

--
Tony Morris
http://tmorris.net/


Re: dangerous import java.sql._

by Tony Morris-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good job, then we shall reveal the problem for all!

The import causes the main method to use java.sql.Array thus making it
an invalid main method for execution.

turicum wrote:

> thank you for the prompt reply!
> everything's fine now :)
> Alex
>
>
> Tony Morris-4 wrote:
>  
>> I shan't spoil it for you, but I shall give ye a hint.
>>
>> When one alters Array for the word scala.Array then all is well.
>>
>> turicum wrote:
>>    
>>> Hi everybody!
>>>
>>> Yet another simple and mysterious problem: with the "import" statement,
>>> running the code will generate a "Exception in thread "main"
>>> java.lang.NoSuchMethodError: main". Removing the "import" solves the
>>> problem. What am I missing? Changing the name of the object does not
>>> modify
>>> the outcome. Thanks!
>>>
>>> import java.sql._ // remove this line to get rid of the error msg
>>>
>>> object Sqltest {
>>> def main(args: Array[String]) {
>>>  print("OK")
>>> }
>>> }
>>>
>>>
>>>  
>>>      
>> --
>> Tony Morris
>> http://tmorris.net/
>>
>>
>>
>>
>>    
>
>  

--
Tony Morris
http://tmorris.net/



Re: dangerous import java.sql._

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In that case, maybe  this will help as well:

import java.sql.{Array=>SQLArray, _}

On Wed, Jul 8, 2009 at 8:55 PM, turicum <turicum@...> wrote:

thank you for the prompt reply!
everything's fine now :)
Alex


Tony Morris-4 wrote:
>
> I shan't spoil it for you, but I shall give ye a hint.
>
> When one alters Array for the word scala.Array then all is well.
>
> turicum wrote:
>> Hi everybody!
>>
>> Yet another simple and mysterious problem: with the "import" statement,
>> running the code will generate a "Exception in thread "main"
>> java.lang.NoSuchMethodError: main". Removing the "import" solves the
>> problem. What am I missing? Changing the name of the object does not
>> modify
>> the outcome. Thanks!
>>
>> import java.sql._ // remove this line to get rid of the error msg
>>
>> object Sqltest {
>>      def main(args: Array[String]) {
>>        print("OK")
>>      }
>> }
>>
>>
>>
>
> --
> Tony Morris
> http://tmorris.net/
>
>
>
>

--
View this message in context: http://www.nabble.com/dangerous-import-java.sql._-tp24401377p24401516.html
Sent from the Scala - User mailing list archive at Nabble.com.




--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: dangerous import java.sql._

by Andrew Gaydenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

java.sql package includes Array interface. I think, with importing you
overwrite scala.Array. Ar a result, you have, in fact,

def main(args: java.sql.Array[String])

instead of

def main(args: scala.Array[String])

As far as main's signature is not expected for legal 'main' method, you get
java.lang.NoSuchMethodError.


On Thursday 09 July 2009 03:55:10 turicum wrote:

> thank you for the prompt reply!
> everything's fine now :)
> Alex
>
> Tony Morris-4 wrote:
> > I shan't spoil it for you, but I shall give ye a hint.
> >
> > When one alters Array for the word scala.Array then all is well.
> >
> > turicum wrote:
> >> Hi everybody!
> >>
> >> Yet another simple and mysterious problem: with the "import" statement,
> >> running the code will generate a "Exception in thread "main"
> >> java.lang.NoSuchMethodError: main". Removing the "import" solves the
> >> problem. What am I missing? Changing the name of the object does not
> >> modify
> >> the outcome. Thanks!
> >>
> >> import java.sql._ // remove this line to get rid of the error msg
> >>
> >> object Sqltest {
> >> def main(args: Array[String]) {
> >>  print("OK")
> >> }
> >> }
> >
> > --
> > Tony Morris
> > http://tmorris.net/


Re: dangerous import java.sql._

by Andrew Gaydenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 09 July 2009 03:59:43 Daniel Sobral wrote:
> In that case, maybe  this will help as well:
> import java.sql.{Array=>SQLArray, _}

.. or full qualifying scala.Array type in main's parameters list.


Re: dangerous import java.sql._

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd suggest not using _ in imports.

2009/7/9 Andrew Gaydenko <a@...>:
> On Thursday 09 July 2009 03:59:43 Daniel Sobral wrote:
>> In that case, maybe  this will help as well:
>> import java.sql.{Array=>SQLArray, _}
>
> .. or full qualifying scala.Array type in main's parameters list.
>
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

Re: dangerous import java.sql._

by Andrew Gaydenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 09 July 2009 13:29:26 Ricky Clarkson wrote:
> I'd suggest not using _ in imports.

+1 to my taste (going from avoiding * in Java).


>
> 2009/7/9 Andrew Gaydenko <a@...>:
> > On Thursday 09 July 2009 03:59:43 Daniel Sobral wrote:
> >> In that case, maybe  this will help as well:
> >> import java.sql.{Array=>SQLArray, _}
> >
> > .. or full qualifying scala.Array type in main's parameters list.