araujox_guntin
01-16-03, 13:12
| I EXECUTE: java getIfxMetaData website 1533 maq website maq password I GOT ERROR: java.sql.SQLException: Database not found or no system permission. at com.informix.jdbc.IfxSqli.addException(IfxSqli.jav a, Compiled Code) at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.jav a, Compiled Code) at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java , Compiled Code) at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.j ava, Compiled Code) at com.informix.jdbc.IfxSqli.executeOpenDatabase(IfxS qli.java, Compiled Code) at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java, Compiled Code) at java.lang.reflect.Constructor.newInstance(Native Method) at com.informix.jdbc.IfxDriver.connect(IfxDriver.java , Compiled Code) at java.sql.DriverManager.getConnection(DriverManager .java, Compiled Code) at java.sql.DriverManager.getConnection(DriverManager .java, Compiled Code) at getIfxMetaData.main(getIfxMetaData.java, Compiled Code) ################################################## ############### MY PATH DB: /apm/habana4/maq.dbs DAEMON: sqlexecd website PLATFORMS: SCO 5.0.6 Informix-SE 7.1 JDK 1.2.2 JDBC 2.21.JC3 SETING FILES: HOSTS FILE: 127.0.0.1 localhost 192.168.0.5 website SQLHOSTS FILE: demo_on onipcshm on_hostname on_servername demo_se seipcpip se_hostname sqlexec website setlitcp website sqlexec SERVICES FILE: sqlexec 1533/tcp # Informix SE sqlexec ENVIRONMENT VARIABLES: INFORMIXDIR=/usr/informix INFORMIXSERVER=website DBPATH=/apm/habana4 PATH=/bin:/etc:/usr/bin:/tcb/bin:$INFORMIXDIR/bin:$INFORMIXDIR/lib CLASSPATH=$CLASSPATH:/usr/java2/bin:/usr/java2:/usr/jdbc/bin:/usr/jdbc:/usr/jdbc/lib/ifxjdbc.jar: /usr/java2/lib/tools.jar PATH=$PATH:/usr/java2:/usr/java2/bin:/usr/jdbc/bin:/usr/jdbc:/usr/jdbc/lib/ifxjdbc.jar getIfxMetaDAta.java FILE //************************************************** ********************** // Overview: // This program is a JAVA application that makes calls to various JDBC // metadata functions, including // getDriverName(), getDriverVersion(), getDatabaseProductName(), // getDatabaseProductVersion(), getTypeInfo(), getStringFunctions(), // getTableTypes(), getTables() // // Software Requirements: // 1. Informix IDS // 2. Java Development Kit // 3. Be sure PATH and CLASSPATH environment variables are set. // PATH needs to be set to include the bin directory of where JDK is // installed (eg. d:\jdk1.3.1_02\bin). CLASSPATH should include // ifxjdbc.jar (eg. d:\informix\jdbc\lib\ifxjdbc.jar). // // Instructions: // 1. javac getIfxMetaData.java // 2. java getIfxMetaData host port database server user password import java.sql.*; class getIfxMetaData { static void getDataAbout(Connection conn) throws SQLException { DatabaseMetaData dmd = conn.getMetaData(); // Get product name String pname = dmd.getDatabaseProductName(); String ver = dmd.getDatabaseProductVersion(); System.out.println("Database Product Name ==> " + pname + " Version "+ver); System.out.println(""); // Get driver name String dname = dmd.getDriverName(); String dver = dmd.getDriverVersion(); System.out.println("Driver ==> " + dname + " Version "+dver); System.out.println(""); // Get description of all datatypes supported by database // Types Class Definition is java.sql.Types System.out.println("DBMS Type java.sql.Types"); System.out.println("------------------------- --------------"); ResultSet rs = dmd.getTypeInfo(); for (int i=1; rs.next(); i++) { String typename = rs.getString("TYPE_NAME"); short dtype = rs.getShort("DATA_TYPE"); int len = typename.length(); StringBuffer stbfr = new StringBuffer(typename); for( int j = 0 ; j < 50 - len ; j ++ ) stbfr = stbfr.append(" "); System.out.println(stbfr.toString() + dtype); } rs.close(); System.out.println(""); // Gets a list of all database string functions String s = dmd.getStringFunctions(); System.out.println("String functions: " + s); System.out.println(""); // Gets a list of all database numeric functions String n = dmd.getNumericFunctions(); System.out.println("Numeric functions: " + n); System.out.println(""); // Gets a list of all database Datetime functions String d = dmd.getTimeDateFunctions(); System.out.println("Datetime functions: " + d); System.out.println(""); // Get list of tables for each table type supported by database ResultSet ttypes = dmd.getTableTypes(); String[] ttypes_array = new String[5]; String[] op_array = new String[1]; for (int i=0; ttypes.next(); i++) { String ttype = ttypes.getString("TABLE_TYPE"); ttypes_array[i] = ttype; op_array[0] = ttypes_array[i]; ResultSet trs = dmd.getTables(null, null, "%" , op_array ); // get the list of the table objects System.out.println("List of tables of type - "+ttype); for (int j=1; trs.next(); j++) { String tabschema = trs.getString("TABLE_SCHEM"); String tabname = trs.getString("TABLE_NAME"); System.out.println(j+".\t "+tabschema+"."+tabname); } System.out.println(""); trs.close(); } } public static void main(String argv[]) { try { // load driver Connection con = null; Class.forName("com.informix.jdbc.IfxDriver").newInstance(); if (argv.length == 6) { String hostname = argv[0]; String portnum = argv[1]; String database = argv[2]; String IfxServer = argv[3]; String userid = argv[4]; String passwd = argv[5]; // URL is "jdbc:informix-sqli://hostname:port-number/dbname:INFORMIXSERVER=server-name;user=userid;password =passwd; /* String url = "jdbc:informix-sqli://" + hostname + ":" + portnum + "/" + database + ":INFORMIXSERVER=" + IfxServer + ";user=" + userid + ";password=" + passwd; */ String url = "jdbc:informix-direct://maq;user=informix;rmm1243"; // connect with default id/password con = DriverManager.getConnection(url); } else { System.out.println("\nUsage: java getIfxMetaData host port database server user password\n"); System.exit(0); } // get metadata about database getDataAbout(con); con.close(); } catch( Exception e ) { e.printStackTrace(); } } } // Here is the Types Class Definition in package java.sql; // public class Types { // public final static int BIT = -7; // public final static int TINYINT = -6; // public final static int SMALLINT = 5; // public final static int INTEGER = 4; // public final static int BIGINT = -5; // public final static int FLOAT = 6; // public final static int REAL = 7; // public final static int DOUBLE = 8; // public final static int NUMERIC = 2; // public final static int DECIMAL = 3; // public final static int CHAR = 1; // public final static int VARCHAR = 12; // public final static int LONGVARCHAR = -1; // public final static int DATE = 91; // public final static int TIME = 92; // public final static int TIMESTAMP = 93; // public final static int BINARY = -2; // public final static int VARBINARY = -3; // public final static int LONGVARBINARY = -4; // public final static int NULL = 0; // public final static int OTHER = 1111; ################################################## ###################################### |