shivani
asked on
java-sybase JDBC Connection
Hi All,
One of employee wrote java code and left now. I am just learning java and trying to figure out the applications he wrote. Well, it is a small company.. so I am the only one to figure out all this..
Anywayz,
I am connecting from JAVA to Sybase using jdbc drivers (jconn2.jar)..(not sure what version of jConnect is it..)
env. is solaris 5.8
and I am getting famous JDBC exception,
java.sql.SQLException: JZ0SJ: Metadata accessor information was not found on this database. Please install the required tables as mentioned in the jConnect documentation.
I don't know how to resolve?
Can somebody pls help me..
well.. I am not sure..
But I am getting this error in some servers.. not all..
May be some servers have different configuration from others.. I don't know..
But I see this error in mails in some servers..
Below is method..
public void dbConnectionDsl() throws Exception {
try {
SybDriver sybDriver = (SybDriver)
Class.forName(SYBASE_STR). newInstanc e();
sybDriver.setVersion(com.s ybase.jdbc x.SybDrive r.VERSION_ 5);
DriverManager.registerDriv er(sybDriv er);
m_connection = DriverManager.getConnectio n (
LOCAL_STR, LOCAL_USR, "");
m_connection.setAutoCommit (false);
} catch(SQLException ex){
System.out.println("Except ion: "+ex);
}
}
Even,
I don't know why,
but
I wrote just a test class
package DslCommon.Util;
import java.util.*;
import java.io.*;
import java.net.*;
import java.sql.*; // Package for JDBC classes
import com.sybase.jdbcx.*; // Package for Sybase JDBC drivers
public class TestBean {
public static final String PORT_SYBASE = "2025";
public static final String LOCAL_STR1 = "jdbc:sybase:Tds:";
public static final String LOCAL_STR2 = ":" + PORT_SYBASE;
public static final String SYBASE_STR = "com.sybase.jdbc2.jdbc.Syb Driver";
static Connection m_connection = null; // Database connection object
public static String LOCAL_STR = LOCAL_STR1+"10"+"."+"2"+". "+"25"+"." +"95"+LOCA L_STR2;
public static final String LOCAL_USR = "sa";
public static void main(String args[]) {
try {
// Load the Sybase JDBC Driver and register it.
SybDriver sybDriver = (SybDriver)
Class.forName(SYBASE_STR). newInstanc e();
sybDriver.setVersion(com.s ybase.jdbc x.SybDrive r.VERSION_ 5);
DriverManager.registerDriv er(sybDriv er);
m_connection = DriverManager.getConnectio n (
LOCAL_STR, LOCAL_USR, ""); // Gets the database connection
// Sets the auto-commit property for the connection to be false.
// By default it is true.
m_connection.setAutoCommit (false);
} catch(Exception ex){ // Trap SQL errors
System.out.println("Sybase Query: dbConnectionDsl: Connect to Dsl Exception: "+ex);
}
}
}
I was able to compile in one solaris box..
but got the below error in other solaris box
DslCommon/Util/TestBean.ja va:7: Package com.sybase.jdbcx not found in import.
import com.sybase.jdbcx.*; // Package for Sybase JDBC drivers
^
1 error
I checked env for both..
Both doesn't have classpath in it..
any ideas for this too?
One of employee wrote java code and left now. I am just learning java and trying to figure out the applications he wrote. Well, it is a small company.. so I am the only one to figure out all this..
Anywayz,
I am connecting from JAVA to Sybase using jdbc drivers (jconn2.jar)..(not sure what version of jConnect is it..)
env. is solaris 5.8
and I am getting famous JDBC exception,
java.sql.SQLException: JZ0SJ: Metadata accessor information was not found on this database. Please install the required tables as mentioned in the jConnect documentation.
I don't know how to resolve?
Can somebody pls help me..
well.. I am not sure..
But I am getting this error in some servers.. not all..
May be some servers have different configuration from others.. I don't know..
But I see this error in mails in some servers..
Below is method..
public void dbConnectionDsl() throws Exception {
try {
SybDriver sybDriver = (SybDriver)
Class.forName(SYBASE_STR).
sybDriver.setVersion(com.s
DriverManager.registerDriv
m_connection = DriverManager.getConnectio
LOCAL_STR, LOCAL_USR, "");
m_connection.setAutoCommit
} catch(SQLException ex){
System.out.println("Except
}
}
Even,
I don't know why,
but
I wrote just a test class
package DslCommon.Util;
import java.util.*;
import java.io.*;
import java.net.*;
import java.sql.*; // Package for JDBC classes
import com.sybase.jdbcx.*; // Package for Sybase JDBC drivers
public class TestBean {
public static final String PORT_SYBASE = "2025";
public static final String LOCAL_STR1 = "jdbc:sybase:Tds:";
public static final String LOCAL_STR2 = ":" + PORT_SYBASE;
public static final String SYBASE_STR = "com.sybase.jdbc2.jdbc.Syb
static Connection m_connection = null; // Database connection object
public static String LOCAL_STR = LOCAL_STR1+"10"+"."+"2"+".
public static final String LOCAL_USR = "sa";
public static void main(String args[]) {
try {
// Load the Sybase JDBC Driver and register it.
SybDriver sybDriver = (SybDriver)
Class.forName(SYBASE_STR).
sybDriver.setVersion(com.s
DriverManager.registerDriv
m_connection = DriverManager.getConnectio
LOCAL_STR, LOCAL_USR, ""); // Gets the database connection
// Sets the auto-commit property for the connection to be false.
// By default it is true.
m_connection.setAutoCommit
} catch(Exception ex){ // Trap SQL errors
System.out.println("Sybase
}
}
}
I was able to compile in one solaris box..
but got the below error in other solaris box
DslCommon/Util/TestBean.ja
import com.sybase.jdbcx.*; // Package for Sybase JDBC drivers
^
1 error
I checked env for both..
Both doesn't have classpath in it..
any ideas for this too?
To fix the compile error you need to add the driver jar either to your classpath, or copy it to your jdk's 'ext' directory.
For the runtime error read your connect doco as suggested.
ASKER
Objects,
I got it.. and they suggested to execute sql_server.sql on our sybase server.
I wanted to know if you or anybody else know it, what does this script do?
I want to make sure what can impact me if I run this script on my sybase server.
I don't know much SQL. So would appreciate help pls.
I have very limited space in my master db and for sybase as a whole.. so want to make sure what does this sql do..
does it just create some tables with some rows in it?
Or just it keep inserting the data in these new tables based on that event..
I mean.. how will it impact my DB in anyway..
Would apreciate help pls
Regards
I got it.. and they suggested to execute sql_server.sql on our sybase server.
I wanted to know if you or anybody else know it, what does this script do?
I want to make sure what can impact me if I run this script on my sybase server.
I don't know much SQL. So would appreciate help pls.
I have very limited space in my master db and for sybase as a whole.. so want to make sure what does this sql do..
does it just create some tables with some rows in it?
Or just it keep inserting the data in these new tables based on that event..
I mean.. how will it impact my DB in anyway..
Would apreciate help pls
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.