Loading from Database

 

WebNMS SNMP API allows loading MIB modules from the database. The MIB files can be stored in any RDBMS, such as MySql or Oracle. Applications can load these MIB files directly from the database.

 

 

Loading MIB files from a database gives the following advantages to applications.

The performance of getting the node information using the database option is less than the other loading options without considering the network traffic.

 

The API uses Java Database Connectivity (JDBC) for the database support. Applications should use a valid JDBC driver of the respective databases to enable the database support.

 

To add database support for loading MIBs, applications should first initialize the necessary database parameters. The initJdbcParams(driverName, URL, userName, passWord)link to javadocs method is used for initializing the database parameters. The following are the arguments of the method.

After initializing the database parameters, the value of the setLoadFromDatabase(boolean flag)link to javadocs method is set to true to enable the database support. By default, the value is set to false.

 

When setLoadFromDatabase() is set to true and loadMibModules(String fileNames)link to javadocs is called, the application loads the MIB file from the database. If the MIB files are not present in the database, the MIB files are loaded in the database and then loaded in the application.

 

After loading the MIB files from the database, if any changes are made to it and loaded again, the changes will not be reflected in the loaded MIB file. The MIB files in the database need to be overwritten. The method setOverwriteDatabase(boolean overWrite)link to javadocs defines whether to overwrite the existing database files.

 

The other methods related to database operations are:

The method setDatabaseName(byte type)link to javadocs is used to set the database. The APIs are tested using the MySql and Oracle databases. The default database is MySql. If you want to set the database to Oracle, the type is set as MibOperations.ORACLE.

 

In case of loading MIBs from a database other than MySql in overwrite option, the method setDatabaseName(byte type)link to javadocs in the MibOperations class should be called before loading the MIBs. Otherwise java.sql.SQLException is thrown.

 

Instructions to use MySql database for loading MIBs

 

The following database parameters are to be configured in the application.

The jar file mysql_comp.jar is to be included in the CLASSPATH. If the jar is not in the CLASSPATH, the following exception is thrown.

 

Java.lang.ClassNotFoundException org.gjt.mm.mysql.Driver

 

Instructions to use Oracle database for loading MIBs

 

The following database parameters are to be configured in the application.

The oracle driver is to be included in the CLASSPATH. If the jar is not in the CLASSPATH, the following exception is thrown.

 

Java.lang.ClassNotFoundException oracle.jdbc.driver.OracleDriver

 

For other databases, use the equivalent parameters.



Copyright © 2009, ZOHO Corp. All Rights Reserved.