Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13

    Unanswered: Java services are not enabled (was "Query problem")

    The query is:

    select max( char_length(ext_desc) - char_length(str_replace(ext_desc, '/', '')) ) from code_orgstructure

    Which like to find the max. number of '/' of column ext_desc. However, I get the following SQLException:

    com.sybase.jdbc2.jdbc.SybSQLException: Cannot run this command because Java services are not enabled. A user with System Administrator (SA) role must reconfigure the system to enable Java.

    What that mean?
    Visit my homepage at http://www.carfield.com.hk

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Don't know why you get that error. Maybe a permissions problem?
    But, to delete a character with str_replace use null instead of the empty string. i.e.
    str_replace(ext_desc, '/', null)

  3. #3
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    I haven't used this before but check:

    sp_configure "java"

    On our server java is not enabled by default so you may need to change the configuration setting(s) to enable java.
    Greetz,

    Bastiaan Olij

  4. #4
    Join Date
    Mar 2006
    Posts
    25

    Unhappy

    I think u should enable java configuration parameter

    sp_configure "enable java",1

    as it is static parameter u should reboot ur server for changes to take place.


    Quote Originally Posted by carfield
    The query is:

    select max( char_length(ext_desc) - char_length(str_replace(ext_desc, '/', '')) ) from code_orgstructure

    Which like to find the max. number of '/' of column ext_desc. However, I get the following SQLException:

    com.sybase.jdbc2.jdbc.SybSQLException: Cannot run this command because Java services are not enabled. A user with System Administrator (SA) role must reconfigure the system to enable Java.

    What that mean?

  5. #5
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13
    Quote Originally Posted by BasOlij
    I haven't used this before but check:

    sp_configure "java"

    On our server java is not enabled by default so you may need to change the configuration setting(s) to enable java.
    Yes, we haven't enable it.... however we host a lot of instance of an application, change the database setting for a database using is hardly possible. Is there similar syntax to do same thing without using java service?
    Visit my homepage at http://www.carfield.com.hk

  6. #6
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Your query is unrelated to the java error message
    Here I execute it without java enabled
    Code:
    create table #code_orgstructure (ext_desc varchar(100))
    insert into #code_orgstructure values ('/d1')
    insert into #code_orgstructure values ('/d1/d2/d3')
    insert into #code_orgstructure values ('/d1/d2')
    exec sp_configure 'enable java'
    select max( char_length(ext_desc) - char_length(str_replace(ext_desc, '/', '')) ) from #code_orgstructure
    select max ( datalength(ext_desc) - datalength(str_replace(ext_desc, '/', null)) ) from #code_orgstructure
    
    Parameter Name                 Default     Memory Used Config Value Run Value   Unit                 Type       
    --------------                 -------     ----------- ------------ ---------   ----                 ----       
    enable java                              0           0           0            0 switch               static     
    
                
    ----------- 
              0 
    
                
    ----------- 
              3

  7. #7
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    Which version of ASE are you running? I read somewhere that the NULL in str_replace(ext_desc, '/', null) is not supported in versions before 12.5.1
    Greetz,

    Bastiaan Olij

  8. #8
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13
    Just try to run

    connection.executeStatement("exec sp_configure 'enable java'");
    connection.executeStatement("select max( char_length(ext_desc) - char_length(str_replace(ext_desc, '/', '')) ) from code_orgstructure");

    But still get the same error.... am I must use str_replace() and there is no corresponding non-java dependence function?
    Visit my homepage at http://www.carfield.com.hk

  9. #9
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    carfield,

    I remember that when you use '' it will not work, but I'm not sure if it supposed to give and error. '' will be changed into a single space but it should still work.

    Anyways, I just looked it up str_replace was introduced in ASE 12.5.0.3, it was then enhanced to accept NULL in 12.5.1

    If you have an older version of Sybase str_replace simply is not supported.

    As for an alternative, I have no idea...
    Greetz,

    Bastiaan Olij

  10. #10
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13
    Quote Originally Posted by BasOlij
    carfield,

    I remember that when you use '' it will not work, but I'm not sure if it supposed to give and error. '' will be changed into a single space but it should still work.

    Anyways, I just looked it up str_replace was introduced in ASE 12.5.0.3, it was then enhanced to accept NULL in 12.5.1

    If you have an older version of Sybase str_replace simply is not supported.

    As for an alternative, I have no idea...
    The error is
    com.sybase.jdbc2.jdbc.SybSQLException: Cannot run this command because Java services are not enabled. A user with System Administrator (SA) role must reconfigure the system to enable Java.

    I even get same error when I run: select max( char_length(ext_desc) - char_length(str_replace(ext_desc, '/', 'a')) ) from code_orgstructure
    Visit my homepage at http://www.carfield.com.hk

  11. #11
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    Hi Carfield,

    Can you run any other java command?

    If you have enabled Java and restarted your server it should work unless if your version of Sybase is to old. Only other thing I can think of is that Java isn't installed correctly. Then again, if I am not mistaken Java is installed along with the Sybase installation.

    Very strange indeed..
    Greetz,

    Bastiaan Olij

  12. #12
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13
    Not sure any other java command exist? However, I think may be I cannot turn on java support using

    connection.executeStatement("exec sp_configure 'enable java'");

    Or may be that server don't have java exist....
    Visit my homepage at http://www.carfield.com.hk

  13. #13
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    Try: connection.executeStatement("exec sp_configure 'enable java', 1");

    Also it returns information about the current setting if you execute it like you just did. If it currently is set to 0 then java is disabled.
    Note that you have to restart your server to make it actually work.

    First though try "select @@version" to get info about your server version.
    Greetz,

    Bastiaan Olij

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •