mallett76 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am trying to run a perl JDBC script, but am running into the error:

DBI connect('hostname=172.28.130.20;port=1025;url=jdbc:teradata://172. +28.130.20/;databaseName=NDW_JRNL_VIEWS','pMalle001',...) failed: Expe +cting tag 0x73875f, found 0x3 at C:/Strawberry/perl/site/lib/Convert/ +BER.pm line 379. ...propagated at C:/Strawberry/perl/site/lib/Convert/BER.pm li +ne 798. at JDBC-ConnectionTestNewNewest.pl line 15. Database connection error: Expecting tag 0x73875f, found 0x3 at C:/Str +awberry/perl/site/lib/Convert/BER.pm line 379. ...propagated at C:/Strawberry/perl/site/lib/Convert/BER.pm li +ne 798.

Here is my code:

use DBI; use JDBC; $user="xxxx"; $password="xxxx"; $url = "jdbc:teradata://172.28.130.20/;databaseName=NED_BASE_VIEWS"; $url =~ s/([=;])/uc sprintf("%%%02x",ord($1))/eg; print $url; $dbh = DBI->connect("dbi:JDBC:hostname=172.28.130.20;port=1025;url=jdb +c:teradata://172.28.130.20/;databaseName=NDW_JRNL_VIEWS", $user, $pas +sword);
  • Comment on On Windows I am trying to run a perl JDBC script, but am running into the error Expecting tag 0x73875f
  • Select or Download Code

Replies are listed 'Best First'.
Re: On Windows I am trying to run a perl JDBC script, but am running into the error Expecting tag 0x73875f
by Corion (Patriarch) on Dec 06, 2023 at 16:42 UTC

    Does the connection work with other tools?

    This sounds very much like a mismatch in either JDBC versions or network protocol version to me.

      Yes, a Java Program works, it does show a certificate error, but, it does at least yield results

      Here is the Java Program that partially works

      package db; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; public class jdbcTeradataConnectionTestCertificate { public static void main(String[] args) throws Exception { try { String serverURL = "jdbc:teradata://172.28.130.20/LOGMECH=LDAP"; // Wo +rked on my laptop, but not main main pc Class.forName("com.teradata.jdbc.TeraDriver"); String username = "!NEDVFCollections"; String password = "xxxxx"; Connection con = DriverManager.getConnection(serverURL, username, pass +word); String query="select top 2* from NED_COLL_TABLES.T_PM_PREPAY_FIN WHERE + SYS = 8773"; PreparedStatement stmt=con.prepareStatement(query); ResultSet rs=stmt.executeQuery(); while(rs.next()) { String col1=rs.getString(1); System.out.println("col1="+col1); } } catch (Exception e) { e.printStackTrace(); } }

      Here are the results it yielded, as one can see, it did print out values "GBR"

      C:\Work\Programming\javaProgrammingLog>java jdbcTeradataConnectionTest +Certificate.java 2023-12-07.10:41:13.437 TERAJDBC4 ERROR [main] com.teradata.jdbc.jdk6. +JDK6_SQL_Connection@783a467b getPeerCertificates failed for connectio +n to /172.28.130.20:443 begin-log-stack-trace>>> javax.net.ssl.SSLPee +rUnverifiedException: peer not authenticated at java.base/sun.security.ssl.SSLSessionImpl.getPeerCertificat +es(SSLSessionImpl.java:1034) at com.teradata.jdbc.jdbc_4.io.CertChecker.checkCert(CertCheck +er.java:67) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.isUsableSocket(TD +NetworkIOIF.java:1424) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.connectToHost(TDN +etworkIOIF.java:614) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.createSocketConne +ction(TDNetworkIOIF.java:185) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.createIO(TDNetwor +kIOIF.java:176) at com.teradata.jdbc.jdbc.GenericTeradataConnection.<init>(Gen +ericTeradataConnection.java:319) at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:18 +8) at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_ +Connection.java:36) at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLCo +nnection(JDK6ConnectionFactory.java:25) at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(C +onnectionFactory.java:181) at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(C +onnectionFactory.java:171) at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:229) at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:164) at java.sql/java.sql.DriverManager.getConnection(DriverManager +.java:683) at java.sql/java.sql.DriverManager.getConnection(DriverManager +.java:230) at db.jdbcTeradataConnectionTestCertificate.main(jdbcTeradataC +onnectionTestCertificate.java:68) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.i +nvoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main +.java:421) at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.jav +a:192) at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.ja +va:132) <<<end-log-stack-trace col1=GBR col1=GBR
Re: On Windows I am trying to run a perl JDBC script, but am running into the error Expecting tag 0x73875f
by Discipulus (Canon) on Dec 07, 2023 at 08:29 UTC
    Just shooting in the dark.. Convert::BER emits the error and the module is non longer maintained and states to use Convert::ASN1 instead. Which module in the chain loads Convert::BER?

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      When I comment out the:

      #use DBI; use JDBC;

      It yields the tag error mentioned initially on this thread

      When I commented out the

      use DBI; #use JDBC;

      It yields the tag error mentioned initially on this thread

      So, to me, both of these modules the use DBI and use JDBC use the Convert::BER

        Yahoo! - After what seems like 3 long years of trying figure it out, I was able to figure it out on some level, with an MS ACCESS connection. Not quite ideal, as I want to connect to Teradata and Trino, but a big step in the right direction. Here is the code for MS Access for others and steps. First, run from the command line:
        set CLASSPATH=C:\JARS\ucanaccess.jar;C:\JARS\hsqldb.jar;C:\JARS\jackce +ss.jar;C:\JARS\commons-lang.jar;C:\JARS\commons-logging.jar; + java -Djdbc.drivers=net.ucanaccess.jdbc.UcanaccessDriver -Ddbd.port=12 +345 com.vizdom.dbd.jdbc.Server
        Then, all you have to do, is run
        use DBI; #COMMENTED OUT ON 2/13/25 my $dsn = "DBI:JDBC:jdbc:ucanaccess://C:/pat +h/to/database.accdb"; #COMMENTED OUT ON 2/20/25 my $dsn = "DBI:JDBC:jdbc:ucanaccess://C:/Wor +k/Programming/jdbcConnectionForNdw/jdbcConnectionForMsAccessTest.accd +b"; #COMMENTED OUT ON 2/27/25 my $dsn = "DBI:JDBC:ucanaccess://C:/Work/Pro +gramming/jdbcConnectionForNdw/jdbcConnectionForMsAccessTest.accdb"; #COMMENTED OUT ON 3/5/25 my $dsn = "dbi:JDBC +:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Work/Progra +mming/jdbcConnectionForNdw/jdbcConnectionForMsAccessTest.accdb"; #commented out on 3 +/5/25 BUT WORKS my $dsn = "dbi:ODBC:Driver={Microsoft Access Driver ( +*.mdb, *.accdb)};Dbq=C:\\Work\\Programming\\jdbcConnectionForNdw\\jdb +cConnectionForMsAccessTest.accdb;"; #COMMENTED OUT ON 3/ +6/25 my $dsn = "dbi:JDBC:Driver={Microsoft Access Driver (*.mdb, *.ac +cdb)};Dbq=C:\\Work\\Programming\\jdbcConnectionForNdw\\jdbcConnection +ForMsAccessTest.accdb;"; #COMMENTED OUT ON 3/6/25 my $dsn = "dbi:JDBC:hostname=localhos +t;port=12345;driver=net.ucanaccess.jdbc.UcanaccessDriver;database=C:/ +Work/Programming/jdbcConnectionForNdw/jdbcConnectionForMsAccessTest.a +ccdb"; my $dsn = "DBI:JDBC:hostname=localhost;port=12345;url=jdbc:uca +naccess:///C:/Work/Programming/jdbcConnectionForNdw/jdbcConnectionFor +MsAccessTest.accdb"; my $dbh = DBI->connect($dsn, '', '', { RaiseError => 1 }) or die "Failed to connect to the database: $DBI::errstr"; print "Connected successfully!\n";
        A few important notes I found installing the BUNDLE JDBC, not the JDBC was better, as the bundle jdbc has the right encoding modules included.