13 Replies Latest reply: Sep 10, 2007 5:04 AM by 807600 RSS

    jdbc  in linux

    807600
      Hi,
      I can install jdbc in windows xp professional. but i am unable to install it in linux.
      In my linux box, java is installed by default. But i dont know where my java is installed.
      I know to install jdbc i have to copy and past
      mysql-connector-java-5.0.7-bin.jar file in java //ext/ directory,
      but i dont know where is java installed in linux.

      Can any one will please tell me, how to install jdbc in linux ??
      how to find out where java is installed?( i tried with /alternatives -- display java) which is more confusing to me.

      if i need to edit any path how to do that.

      Thanks

      Message was edited by:
      Fosiul
        • 1. Re: jdbc  in linux
          807600
          Checking your environment variables on Linux might be a good idea. There might be a variable called JAVA_HOME pointing to your Java installation directory, or you may have to find it from the directory mentioned in PATH.

          It is also not a good idea to put JDBC driver jars in java/ext directory mainly because database drivers are not an extension of java. You can include any jar you want in your program classpath or set a global CLASSPATH in the environment to include your MySQL jar.
          • 2. Re: jdbc  in linux
            807600
            Thanks for reply.
            check the bello code,
            [root@linux share]# echo $PATH
            /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

            where is java path ?? how will i know , where is java install from this path information ??
            • 3. Re: jdbc  in linux
              807600
              whereis java
              will show you
              • 4. Re: jdbc  in linux
                807600
                whereis java
                will show you
                here is commmand :
                [root@linux java]# whereis java
                java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /opt/j2sdk1.4.2_13/bin/java

                and here is my java.conf

                [root@linux java]# cat java.conf
                # System-wide Java configuration file -- sh --
                #
                # JPackage Project <http://www.jpackage.org/>

                # Location of jar files on the system
                JAVA_LIBDIR=/usr/share/java

                # Location of arch-specific jar files on the system
                JNI_LIBDIR=/usr/lib/java

                # Root of all JVM installations
                JVM_ROOT=/usr/lib/jvm

                # Default jvm
                JAVA_HOME=$JVM_ROOT/java

                # Options to pass to the java interpreter
                JAVACMD_OPTS=


                ------------------------------------

                Where my mysql-connector-java-5.0.7-bin.jar file will go ??

                Message was edited by:
                Fosiul
                • 5. Re: jdbc  in linux
                  800308
                  mysql-connector-java-5.0.7-bin.jar file will go ANYWHERE. You just need to say where-ever you chose to put it in the classpath.

                  As previously stated putting 3rd party jar's in java/ext/ (even for tomcat) WILL cause you problems later.

                  It's much better to specify all the required jar's with the -classpath (-cp in 1.6) argument on the command line when you compile and run... or better still learn how to use Ant early on... it'll save you heaps of hastles, and you'll end up learning it sooner or later anyway.
                  • 6. Re: jdbc  in linux
                    807600
                    mysql-connector-java-5.0.7-bin.jar file will go
                    ANYWHERE. You just need to say where-ever you chose
                    to put it in the classpath.

                    As previously stated putting 3rd party jar's in
                    java/ext/ (even for tomcat) WILL cause you problems
                    later.

                    It's much better to specify all the required jar's
                    with the -classpath (-cp in 1.6) argument on the
                    command line when you compile and run... or better
                    still learn how to use Ant early on... it'll save you
                    heaps of hastles, and you'll end up learning it
                    sooner or later anyway.
                    Thanks,
                    I understood, i can put .jar anywhere in java but i have to put in classpath
                    but problem is, how ?
                    can you please write a sample code for putting .jar in class path
                    or i will be please if any one can write the syntax for me to put in path

                    file name is mysql-connector-java-5.0.7-bin.jar
                    • 7. Re: jdbc  in linux
                      807600
                      mysql-connector-java-5.0.7-bin.jar file will go
                      ANYWHERE. You just need to say where-ever you chose
                      to put it in the classpath.

                      As previously stated putting 3rd party jar's in
                      java/ext/ (even for tomcat) WILL cause you problems
                      later.

                      It's much better to specify all the required jar's
                      with the -classpath (-cp in 1.6) argument on the
                      command line when you compile and run... or better
                      still learn how to use Ant early on... it'll save you
                      heaps of hastles, and you'll end up learning it
                      sooner or later anyway.
                      I used this command:
                      [root@linux driver]# export CLASSPATH=.:/user/local/driver/mysql-connector-java-5.0.7-bin.jar

                      [root@linux driver]# export | grep CLASSPATH
                      declare -x CLASSPATH=".:/user/local/driver/mysql-connector-java-5.0.7-bin.jar"

                      When i am trying to execute command from java to access jdbc -

                      [root@linux java]# java JdbcExample1
                      Exception: com.mysql.jdbc.Driver not found in [file:./, file:/user/local/driver/mysql-connector-java-5.0.7-bin.jar, file:/usr/share/java/libgcj-3.4.6.jar, file:./, core:/]
                      • 8. Jdbc configuration problem in linux
                        807600
                        Hi expert
                        any more suggestion of my problem ??
                        Please give me some clue.

                        Message was edited by:
                        Fosiul
                        • 9. Re: jdbc  in linux
                          807600
                          mysql-connector-java-5.0.7-bin.jar file will go
                          ANYWHERE. You just need to say where-ever you
                          chose
                          to put it in the classpath.

                          As previously stated putting 3rd party jar's in
                          java/ext/ (even for tomcat) WILL cause you
                          problems
                          later.

                          It's much better to specify all the required jar's
                          with the -classpath (-cp in 1.6) argument on the
                          command line when you compile and run... or better
                          still learn how to use Ant early on... it'll save
                          you
                          heaps of hastles, and you'll end up learning it
                          sooner or later anyway.
                          I used this command:
                          [root@linux driver]# export
                          CLASSPATH=.:/user/local/driver/mysql-connector-java-5.
                          0.7-bin.jar

                          [root@linux driver]# export | grep CLASSPATH
                          declare -x
                          CLASSPATH=".:/user/local/driver/mysql-connector-java-5
                          .0.7-bin.jar"

                          When i am trying to execute command from java to
                          access jdbc -

                          [root@linux java]# java JdbcExample1
                          Exception: com.mysql.jdbc.Driver not found in
                          [file:./,
                          file:/user/local/driver/mysql-connector-java-5.0.7-bin
                          .jar, file:/usr/share/java/libgcj-3.4.6.jar, file:./,
                          core:/]
                          after changing some codce
                          -------------------------------------
                          [root@linux driver]# export | grep CLASSPATH
                          declare -x
                          CLASSPATH=".:/user/local/driver/mysql-connector-java-5
                          .0.7-bin.jar"
                          when i am running java programm - its giving me bellow error :
                          Can any one please explain me ?

                          Exception: Error during query: Unexpected Exception: java.io.CharConversionException message given: null

                          Nested Stack Trace:


                          ** BEGIN NESTED EXCEPTION **

                          java.io.CharConversionException

                          STACKTRACE:

                          java.io.CharConversionException
                          at gnu.gcj.convert.Input_iconv.read(char[], int, int) (/usr/lib/libgcj.so.5.0.0)
                          at java.lang.String.init(byte[], int, int, java.lang.String) (/usr/lib/libgcj.so.5.0.0)
                          at java.lang.String.String(byte[], int, int, java.lang.String) (/usr/lib/libgcj.so.5.0.0)
                          at com.mysql.jdbc.SingleByteCharsetConverter.SingleByteCharsetConverter(java.lang.String) (Unknown Source)
                          at com.mysql.jdbc.SingleByteCharsetConverter.initCharset(java.lang.String) (Unknown Source)
                          at com.mysql.jdbc.SingleByteCharsetConverter.getInstance(java.lang.String, com.mysql.jdbc.Connection) (Unknown Source)
                          at com.mysql.jdbc.Connection.getCharsetConverter(java.lang.String) (Unknown Source)
                          at com.mysql.jdbc.StringUtils.getBytes(java.lang.String, java.lang.String, java.lang.String, boolean, com.mysql.jdbc.Connection) (Unknown Source)
                          at com.mysql.jdbc.Buffer.writeStringNoNull(java.lang.String, java.lang.String, java.lang.String, boolean, com.mysql.jdbc.Connection) (Unknown Source)
                          at com.mysql.jdbc.MysqlIO.sqlQueryDirect(com.mysql.jdbc.Statement, java.lang.String, java.lang.String, com.mysql.jdbc.Buffer, int, com.mysql.jdbc.Connection, int, int, boolean, java.lang.String, boolean) (Unknown Source)
                          at com.mysql.jdbc.Connection.execSQL(com.mysql.jdbc.Statement, java.lang.String, int, com.mysql.jdbc.Buffer, int, int, boolean, java.lang.String, boolean, boolean) (Unknown Source)
                          at com.mysql.jdbc.Connection.configureClientCharacterSet() (Unknown Source)
                          at com.mysql.jdbc.Connection.initializePropsFromServer() (Unknown Source)
                          at com.mysql.jdbc.Connection.createNewIO(boolean) (Unknown Source)
                          at com.mysql.jdbc.Connection.Connection(java.lang.String, int, java.util.Properties, java.lang.String, java.lang.String) (Unknown Source)
                          at com.mysql.jdbc.NonRegisteringDriver.connect(java.lang.String, java.util.Properties) (Unknown Source)
                          at java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties) (/usr/lib/libgcj.so.5.0.0)
                          at java.sql.DriverManager.getConnection(java.lang.String, java.lang.String, java.lang.String) (/usr/lib/libgcj.so.5.0.0)
                          at JdbcExample1.main(java.lang.String[]) (Unknown Source)


                          ** END NESTED EXCEPTION **
                          • 10. Re: jdbc  in linux
                            807600
                            when i am running java programm - its giving me
                            bellow error :
                            Can any one please explain me ?

                            Exception: Error during query: Unexpected Exception:
                            java.io.CharConversionException message given: null
                            http://forums.mysql.com/read.php?39,142452,142452
                            • 11. Re: jdbc  in linux (Solved)
                              807600
                              Hi every one
                              Thanks for helping me to solve this problem
                              I successfully solved this problem .
                              Thanks
                              • 12. Re: jdbc  in linux (Solved)
                                800308
                                How?
                                • 13. Re: jdbc  in linux (Solved)
                                  807600
                                  The problem was happaning because , Home directory of java was set to old java. although i had installed latest java.

                                  so, i had to change the home direcotory of java to new one.

                                  then set the path of mysql-connector-java-5.
                                  0.7-bin.jar

                                  it will work.