0

I hope I am not repeating a question but I googled and googled and could not find the answer. I need to get data of Hybris database. The guys at hybris sent me a url to connect to and said I need to run a jdbc client in order to do so. as I am running Perl code I tried following the steps described in this url: http://search.cpan.org/~vizdom/DBD-JDBC/JDBC.pod I coded this:

my $host = 127.0.0.1; 
my $port = 9001;
my $url = "a url provided by Hybris";
$url =~ s/([=;])/uc sprintf("%%%02x",ord($1))/eg;
my $dsn = "dbi:JDBC:hostname=$host;port=$port;url=$url;";

my %properties = 
(
    'user' => 'User provided by Hybris', 
    'password' => 'password provided by Hybris', 
    'host.name' => 'hostname from url provided by Hybris', 
    'host.port' => 'port provided by Hybris'
);

my $dbh = DBI->connect($dsn, undef, undef, { PrintError => 0, RaiseError => 1, jdbc_properties => \%properties } ) or die "Failed to connect: ($DBI::err) $DBI::errstr\n";`

I am sorry but cannot provide actual url and user name as this is a production system. I keep getting an error:

DBD::JDBC initialisation failed: Can't locate object method "driver" via package
 "DBD::JDBC" at C:/Perl64/lib/DBI.pm line 811.

Perhaps the capitalisation of DBD 'JDBC' isn't right. at monitorHybrisDB.pl line
 23

( The server from the perl URL loaded OK )

I tried googling this error but so far I found nothing but some more people with the same problem.

When I tried coding in Java I wrote the following code:

public class GetHybrisOrders {
    public static void main(String[] args) throws SQLException {
        try {
            // The newInstance() call is a work around for some
            // broken Java implementations

            Class.forName("de.hybris.vjdbc.VirtualDriver").newInstance();
        } catch (Exception ex) {
            // handle the error
        }

        Connection conn = null;
         try {
         conn =
         DriverManager.getConnection("jdbc:hybris:flexiblesearch:url Provided by hybris =username &password=password provided by hybris");

         // Do something with the Connection

         } catch (SQLException ex) {
         // handle any errors
         System.out.println("SQLException: " + ex.getMessage());
         System.out.println("SQLState: " + ex.getSQLState());
         System.out.println("VendorError: " + ex.getErrorCode());
         }

    }
}

I keep getting this stack trace:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at de.hybris.vjdbc.VirtualDriver.<clinit>(VirtualDriver.java:39)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at GetHybrisOrders.main(GetHybrisOrders.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

Can anyone help me with finding a splution in either Java or Perl?

thanks, Adam

  • 2
    you need to add apache logging jar (and any other jar that is used) to the classpath – Sharon Ben Asher Jul 02 '17 at 08:44
  • see https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – Sharon Ben Asher Jul 02 '17 at 08:45
  • Thanks. This is what I thought. Is this I standard jar or should it be provided by the Hybris people? – Adam Borenstien Jul 02 '17 at 08:51
  • Apache is an independant organization that publishes its own jar files. However, that does not mean that the "Hybris people" don't have a distribution that includes all dependencies. However, usually, dependencies are handled via a dependency managemenat tool, like Apache maven or Apache Ivy. Usually, your IDE (Eclipse, NetBeans, etc) has built in support for this – Sharon Ben Asher Jul 02 '17 at 09:01
  • I believe "dependency managemenat" is a cross-language term since 3rd party libraries exist in all development platforms... – Sharon Ben Asher Jul 02 '17 at 09:04
  • could you show your complete perl code, or at least enough to duplicate the problem (without the sensitive information)? what happens if you run `perl -e'use DBD::JDBC'`? – ysth Jul 02 '17 at 15:34
  • @AdamBorenstien Did you manage to resolve this issue ? – pauldx Apr 14 '21 at 18:31
  • @pauldx, i think i did, if i remember i used Java to get the data from the DB. – Adam Borenstien Apr 15 '21 at 07:40
  • @AdamBorenstien - I am trying to use DBD::JDBC and getting all sorts of trouble configuring it ... are you saying your Perl code that you have mentioned with Hybris was finally able to connect ? also I assume your spin up JDBC server first and then ran that Perl code and if you any perquisite steps remember then it is great . thanks! – pauldx Apr 15 '21 at 16:10
  • Hi @pauldx not sure what i did there. i got it eorking but it was a long time ago and i no longer work for that company – Adam Borenstien Feb 10 '22 at 19:54

0 Answers0