/usr/share/doc/my-server-5.0/examples. I am also attaching a my.cnf here that is taken out from CentOS 4 installation of LxAdmin (which has been famous for its low-memory foot print). It is pretty much based on my-small.cnf. Some important notes:
*
skip-bdb and skip-innodb are added, so you don’t get BSD DB nor InnoDB support. BSD DB support in MySQL is pretty much obsolete, and many open source scripts don’t rely on the presence of InnoDB. A low end VPS is not likely to enjoy the concurrency InnoDB is offering anyway. Transaction and referential integrity? Real ProgrammersTM write their own rollback routines :)
*
key_buffer is only 16K which is far from enough. key_buffer is pretty much one of the most important parameter for MyISAM tables and I usually bump it up to at least 1MB. The same can be said about table_cache — 4 is way too small. A WordPress page will likely touch 10 tables, and much more for apps like Drupal or MediaWiki.
*
Query cache might be a good thing if you intend to run a busy site on such a low end VPS (provided that it has small data set, mostly read, like blogs, news sites, etc). I have my query_cache_limit set to 256K and query_cache_size set to 4M here.
Sunday, July 31, 2011
Thursday, July 28, 2011
what is a apachi log4j Explain Log4j / interview question
Explain Log4j / interview question
Logging within the context of program development constitutes inserting statements into the program that provide some kind of output information that is useful to the developer.
Log4j provide mathod
1. error()
2. fatal()
3. info()
4. debug()
5. warn()
Requirtments
log4j.jar -->lib/log4j-1.2.6.jar
log4j.xml
Finally configured the program
when will occur the erro during runtime
Eample of the Program
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.FileAppender;
public class simpandfile {
static Logger logger = Logger.getLogger(simpandfile.class);
public static void main(String args[]) {
SimpleLayout layout = new SimpleLayout();
FileAppender appender = null;
try {
appender = new FileAppender(layout,"output1.txt",false);
} catch(Exception e) {}
logger.addAppender(appender);
logger.setLevel((Level) Level.DEBUG);
logger.debug("Here is some DEBUG");
logger.info("Here is some INFO");
logger.warn("Here is some WARN");
logger.error("Here is some ERROR");
logger.fatal("Here is some FATAL");
}
}
what is Log4J and it's advantages & disadvantages ?
Logging within the context of program development constitutes inserting statements into the program that provide some kind of output information that is useful to the developer.
Log4j provide mathod
1. error()
2. fatal()
3. info()
4. debug()
5. warn()
Requirtments
log4j.jar -->lib/log4j-1.2.6.jar
log4j.xml
Finally configured the program
when will occur the erro during runtime
Eample of the Program
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.FileAppender;
public class simpandfile {
static Logger logger = Logger.getLogger(simpandfile.class);
public static void main(String args[]) {
SimpleLayout layout = new SimpleLayout();
FileAppender appender = null;
try {
appender = new FileAppender(layout,"output1.txt",false);
} catch(Exception e) {}
logger.addAppender(appender);
logger.setLevel((Level) Level.DEBUG);
logger.debug("Here is some DEBUG");
logger.info("Here is some INFO");
logger.warn("Here is some WARN");
logger.error("Here is some ERROR");
logger.fatal("Here is some FATAL");
}
}
Configuring Log4J
As you can see above we added the log4j library. This library does like a configuration file in the source directory or it welcomes you with the following error.
log4j:WARN No appenders could be found for logger (TestClient).
log4j:WARN Please initialize the log4j system properly.
Create a file named log4j.properties in the root directory and insert the following:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L – %m%n
### set log levels – for more verbose logging change ‘info’ to ‘debug’ ###
log4j.rootLogger=debug, stdout
log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=debug
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
### log just the SQL
log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=info
### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
### log cache activity ###
log4j.logger.org.hibernate.cache=info
### log transaction activity
#log4j.logger.org.hibernate.transaction=debug
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
As you can see above we added the log4j library. This library does like a configuration file in the source directory or it welcomes you with the following error.
log4j:WARN No appenders could be found for logger (TestClient).
log4j:WARN Please initialize the log4j system properly.
Create a file named log4j.properties in the root directory and insert the following:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L – %m%n
### set log levels – for more verbose logging change ‘info’ to ‘debug’ ###
log4j.rootLogger=debug, stdout
log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=debug
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
### log just the SQL
log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=info
### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
### log cache activity ###
log4j.logger.org.hibernate.cache=info
### log transaction activity
#log4j.logger.org.hibernate.transaction=debug
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
log4j.properties
# Set root logger level to DEBUG and its only appender to Appender1.
log4j.rootLogger=INFO, Appender1,Appender2
# Appender1 is set to be a ConsoleAppender.
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender2=org.apache.log4j.RollingFileAppender
log4j.appender.Appender2.File=sample.log
# Appender2 uses PatternLayout.
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m %n" />
</layout>
</appender>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="INFO" />
<param name="File" value="sample.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m %n" />
</layout>
</appender>
<logger name="javabeat.net.log4j" additivity="false" >
<level value="INFO" />
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
</log4j:configuration>
Log4jPropertyTest.java
package javabeat.net.log4j;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
/**
* source : www.javabeat.net
*/
public class Log4jPropertyTest {
private static Logger logger = Logger.getLogger(Log4jPropertyTest.class);
public static void main (String args[]){
PropertyConfigurator.configure("log4j.properties");
logger.info("Test Log");
}
}
Log4jXmlTest.java
package javabeat.net.log4j;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
/**
* source : www.javabeat.net
*/
public class Log4jXmlTest {
private static Logger logger = Logger.getLogger(Log4jXmlTest.class);
public static void main (String args[]){
DOMConfigurator.configure("log4j.xml");
logger.info("Test Log");
}
}
what is Log4J and it's advantages & disadvantages ?
What is a Trigger explain tips oracle mysql advantage
Explain Trigger
A trigger is a pl/sql block structure which is fired when a DML statements like Insert, Delete, Update is executed on a database table. A trigger is triggered automatically when an associated DML statement is executed.
Types of PL/SQL Triggers
There are two types of triggers based on the which level it is triggered.
1) Row level trigger - An event is triggered for each row upated, inserted or deleted.
2) Statement level trigger - An event is triggered for each sql statement executed.
PL/SQL Trigger Execution Hierarchy
The following hierarchy is followed when a trigger is fired.
1) BEFORE statement trigger fires first.
2) Next BEFORE row level trigger fires, once for each row affected.
3) Then AFTER row level trigger fires once for each affected row. This events will alternates between BEFORE and AFTER row level triggers.
4) Finally the AFTER statement level trigger fires.
Create Table Stu_Table
Create Table Stu_Table( Stu_Id int, Stu_Name varchar(15),Stu_Class int); |
create table stu_log( user_id VARCHAR(15), description VARCHAR(100)); |
The below Query create a Trigger 'stu_update' on
table stu_table.
delimiter $$CREATE TRIGGER stu_updateAFTER UPDATE ON stu_table FOR EACH ROW |
Insert Data Into Stu_Table
insert into stu_table values(1, 'Komal',10); |
+--------+----------+-----------+ |
update stu_table set Stu_Class = stu_class+1; |
+--------+----------+-----------+ |
View Advantage and disadvantage oracle
View Advantage and disadvantage oracle
A view is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used
Benefits of Oracle Views
Oracle views offer some compelling benefits. These include:
* Commonality of code being used. Since a view is based on one common set of SQL, this means that when it is called it’s less likely to require parsing. This is because the basic underlying SQL that is called is always the same. However, since you can add additional where clauses when calling a view, you still need to use bind variables. Additional where clauses without a bind variable can still cause a hard parse!
* Security. Views have long been used to hide the tables that actually contain the data you are querying. Also, views can be used to restrict the columns that a given user has access to. Using views for security on less complex databases is probably not a bad thing. As databases become more complex, this solution becomes harder to scale and other solutions will be needed.
* Predicate pushing. Oracle supports pushing of predicates into a given view. Assume we had a set of layered views, like this:
create view viewsample as
select ct_name,ct_description,first_name
from category,employee group by first_name
select * from viewsample
1)Simple Views:
•The view which is created by selecting only one table.
•A Simple view does not contain functions.
•You can always perform DML operations through Simple views.
2)Complex Views:
•The view which is created by selecting more than one tables.
•A Complex view contains functions.
•You cannot always perform DML through Complex views.
Rules for performing DML Operations on a view:
•You can perform DML operations on Simple views.
•You cannot always perform DML through Complex views.
•You cannot delete a row if the view contains the following:
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
• You cannot update data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
• You cannot insert data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
There are NOT NULL columns in the base tables that are not selected by the view.
A view is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used
Benefits of Oracle Views
Oracle views offer some compelling benefits. These include:
* Commonality of code being used. Since a view is based on one common set of SQL, this means that when it is called it’s less likely to require parsing. This is because the basic underlying SQL that is called is always the same. However, since you can add additional where clauses when calling a view, you still need to use bind variables. Additional where clauses without a bind variable can still cause a hard parse!
* Security. Views have long been used to hide the tables that actually contain the data you are querying. Also, views can be used to restrict the columns that a given user has access to. Using views for security on less complex databases is probably not a bad thing. As databases become more complex, this solution becomes harder to scale and other solutions will be needed.
* Predicate pushing. Oracle supports pushing of predicates into a given view. Assume we had a set of layered views, like this:
create view viewsample as
select ct_name,ct_description,first_name
from category,employee group by first_name
select * from viewsample
1)Simple Views:
•The view which is created by selecting only one table.
•A Simple view does not contain functions.
•You can always perform DML operations through Simple views.
2)Complex Views:
•The view which is created by selecting more than one tables.
•A Complex view contains functions.
•You cannot always perform DML through Complex views.
Rules for performing DML Operations on a view:
•You can perform DML operations on Simple views.
•You cannot always perform DML through Complex views.
•You cannot delete a row if the view contains the following:
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
• You cannot update data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
• You cannot insert data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
There are NOT NULL columns in the base tables that are not selected by the view.
Types of View:
View can be categorized into two. The differences between simple and complex view also listed below.
1)Simple Views:
•The view which is created by selecting only one table.
•A Simple view does not contain functions.
•You can always perform DML operations through Simple views.
2)Complex Views:
•The view which is created by selecting more than one tables.
•A Complex view contains functions.
•You cannot always perform DML through Complex views.
Rules for performing DML Operations on a view:
•You can perform DML operations on Simple views.
•You cannot always perform DML through Complex views.
•You cannot delete a row if the view contains the following:
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
• You cannot update data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
• You cannot insert data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
There are NOT NULL columns in the base tables that are not selected by the view.
http://arjudba.blogspot.com/2009/12/oracle-object-type-exercises-varray.html
http://arjudba.blogspot.com/2009/12/practice-oracle-joins-examples.html
http://arjudba.blogspot.com/2009/12/oracle-security-practices.html
http://arjudba.blogspot.com/2009/12/exercises-with-oracle-create-table-add.html
http://arjudba.blogspot.com/2009/12/oracle-database-creation-exercises.html
http://arjudba.blogspot.com/2009/12/basic-oracle-sql-exercise.html
http://arjudba.blogspot.com/2009/08/format-model-modifiers-fx-and-fm.html
http://arjudba.blogspot.com/2009/08/number-format-models-in-oracle.html
http://arjudba.blogspot.com/2009/08/format-models-in-oracle.html
http://arjudba.blogspot.com/2009/07/sql-decode.html
http://arjudba.blogspot.com/2009/07/how-to-know-row-of-table-belong-to.html
http://arjudba.blogspot.com/2009/06/how-to-know-which-objects-are-being.html
http://arjudba.blogspot.com/2009/06/ddl-with-wait-option-in-11g.html
http://arjudba.blogspot.com/2009/06/ora-00939-too-many-arguments-when-case.html
http://arjudba.blogspot.com/2009/03/oracle-datatype-internal-code.html
http://arjudba.blogspot.com/2009/03/how-to-know-list-of-constraints-and.html
http://arjudba.blogspot.com/2009/02/how-to-know-dependent-objectswhich.html
http://arjudba.blogspot.com/2009/02/how-to-search-stringkey-value-from.html
http://arjudba.blogspot.com/2009/02/how-to-know-when-tableobjects-ddlcode.html
http://arjudba.blogspot.com/2009/02/ora-00920-invalid-relational-operator.html
http://arjudba.blogspot.com/2009/01/adding-default-value-to-column-on-table.html
http://arjudba.blogspot.com/2009/01/ora-12838-cannot-readmodify-object.html
http://arjudba.blogspot.com/2009/01/ora-01779-cannot-modify-column-which.html
http://arjudba.blogspot.com/2009/01/updating-table-based-on-another-table.html
http://arjudba.blogspot.com/2009/01/ora-00054-resource-busy-and-acquire.html
http://arjudba.blogspot.com/2008/12/troubleshoot-ora-02292-ora-02449-and.html
http://arjudba.blogspot.com/2008/06/ora-00903-oracle-database-reserved.html
http://arjudba.blogspot.com/2008/06/hints-in-oracle.html
http://arjudba.blogspot.com/2008/06/examples-of-usage-of-composite-index.html
http://arjudba.blogspot.com/2008/06/find-indexes-and-assigned-columns-for.html
http://arjudba.blogspot.com/2008/06/reasons-for-using-alter-table-statement.html
http://arjudba.blogspot.com/2008/06/alter-table-rename-table-add-column.html
http://arjudba.blogspot.com/2008/06/ora-01830-date-format-picture-ends.html
http://arjudba.blogspot.com/2008/06/default-date-timestamp-and-timestamp.html
http://arjudba.blogspot.com/2008/06/create-temporary-table-in-oracle.html
http://arjudba.blogspot.com/2008/06/example-of-antijoin-semijoin-curtesian.html
http://arjudba.blogspot.com/2008/12/ora-02297-cannot-disable-constraint.html
http://arjudba.blogspot.com/2008/10/convert-decimal-to-hexadecimal-on.html
http://arjudba.blogspot.com/2008/10/how-to-generate-fibonacci-series-in.html
http://arjudba.blogspot.com/2008/10/same-sounded-words-in-oracle.html
http://arjudba.blogspot.com/2008/09/type-of-constraint-in-oracle.html
http://arjudba.blogspot.com/2008/09/how-to-move-lob-data-to-another.html
http://arjudba.blogspot.com/2008/08/subqueries-in-oracle-with-example.html
http://arjudba.blogspot.com/2008/08/how-to-monitor-alert-log-file-in-oracle.html
http://arjudba.blogspot.com/2008/08/solution-of-ora-01873-leading-precision.html
http://arjudba.blogspot.com/2008/07/literals-and-literal-types-in-oracle.html
http://arjudba.blogspot.com/2008/07/ora-01722-invalid-number.html
http://arjudba.blogspot.com/2008/07/ora-00936-missing-expression.html
http://arjudba.blogspot.com/2008/07/ora-01756-quoted-string-not-properly.html
http://arjudba.blogspot.com/2008/07/pls-00428-into-clause-is-expected-in.html
http://arjudba.blogspot.com/2008/07/schema-object-naming-rules.html
http://arjudba.blogspot.com/2008/06/datetime-and-interval-datatypes.html
http://arjudba.blogspot.com/2008/06/large-object-lob-datatypes-with-example.html
http://arjudba.blogspot.com/2008/06/history-of-sql.html
http://arjudba.blogspot.com/2008/06/what-is-sql.html
View can be categorized into two. The differences between simple and complex view also listed below.
1)Simple Views:
•The view which is created by selecting only one table.
•A Simple view does not contain functions.
•You can always perform DML operations through Simple views.
2)Complex Views:
•The view which is created by selecting more than one tables.
•A Complex view contains functions.
•You cannot always perform DML through Complex views.
Rules for performing DML Operations on a view:
•You can perform DML operations on Simple views.
•You cannot always perform DML through Complex views.
•You cannot delete a row if the view contains the following:
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
• You cannot update data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
• You cannot insert data in a view if it contains,
Group functions such as SUM, MIN, MAX, AVG and ......
A GROUP BY clause.
The DISTINCT keyword.
Columns defined by expressions such as SALARY*1.2
The ROWNUM pseudo column.
There are NOT NULL columns in the base tables that are not selected by the view.
http://arjudba.blogspot.com/2009/12/oracle-object-type-exercises-varray.html
http://arjudba.blogspot.com/2009/12/practice-oracle-joins-examples.html
http://arjudba.blogspot.com/2009/12/oracle-security-practices.html
http://arjudba.blogspot.com/2009/12/exercises-with-oracle-create-table-add.html
http://arjudba.blogspot.com/2009/12/oracle-database-creation-exercises.html
http://arjudba.blogspot.com/2009/12/basic-oracle-sql-exercise.html
http://arjudba.blogspot.com/2009/08/format-model-modifiers-fx-and-fm.html
http://arjudba.blogspot.com/2009/08/number-format-models-in-oracle.html
http://arjudba.blogspot.com/2009/08/format-models-in-oracle.html
http://arjudba.blogspot.com/2009/07/sql-decode.html
http://arjudba.blogspot.com/2009/07/how-to-know-row-of-table-belong-to.html
http://arjudba.blogspot.com/2009/06/how-to-know-which-objects-are-being.html
http://arjudba.blogspot.com/2009/06/ddl-with-wait-option-in-11g.html
http://arjudba.blogspot.com/2009/06/ora-00939-too-many-arguments-when-case.html
http://arjudba.blogspot.com/2009/03/oracle-datatype-internal-code.html
http://arjudba.blogspot.com/2009/03/how-to-know-list-of-constraints-and.html
http://arjudba.blogspot.com/2009/02/how-to-know-dependent-objectswhich.html
http://arjudba.blogspot.com/2009/02/how-to-search-stringkey-value-from.html
http://arjudba.blogspot.com/2009/02/how-to-know-when-tableobjects-ddlcode.html
http://arjudba.blogspot.com/2009/02/ora-00920-invalid-relational-operator.html
http://arjudba.blogspot.com/2009/01/adding-default-value-to-column-on-table.html
http://arjudba.blogspot.com/2009/01/ora-12838-cannot-readmodify-object.html
http://arjudba.blogspot.com/2009/01/ora-01779-cannot-modify-column-which.html
http://arjudba.blogspot.com/2009/01/updating-table-based-on-another-table.html
http://arjudba.blogspot.com/2009/01/ora-00054-resource-busy-and-acquire.html
http://arjudba.blogspot.com/2008/12/troubleshoot-ora-02292-ora-02449-and.html
http://arjudba.blogspot.com/2008/06/ora-00903-oracle-database-reserved.html
http://arjudba.blogspot.com/2008/06/hints-in-oracle.html
http://arjudba.blogspot.com/2008/06/examples-of-usage-of-composite-index.html
http://arjudba.blogspot.com/2008/06/find-indexes-and-assigned-columns-for.html
http://arjudba.blogspot.com/2008/06/reasons-for-using-alter-table-statement.html
http://arjudba.blogspot.com/2008/06/alter-table-rename-table-add-column.html
http://arjudba.blogspot.com/2008/06/ora-01830-date-format-picture-ends.html
http://arjudba.blogspot.com/2008/06/default-date-timestamp-and-timestamp.html
http://arjudba.blogspot.com/2008/06/create-temporary-table-in-oracle.html
http://arjudba.blogspot.com/2008/06/example-of-antijoin-semijoin-curtesian.html
http://arjudba.blogspot.com/2008/12/ora-02297-cannot-disable-constraint.html
http://arjudba.blogspot.com/2008/10/convert-decimal-to-hexadecimal-on.html
http://arjudba.blogspot.com/2008/10/how-to-generate-fibonacci-series-in.html
http://arjudba.blogspot.com/2008/10/same-sounded-words-in-oracle.html
http://arjudba.blogspot.com/2008/09/type-of-constraint-in-oracle.html
http://arjudba.blogspot.com/2008/09/how-to-move-lob-data-to-another.html
http://arjudba.blogspot.com/2008/08/subqueries-in-oracle-with-example.html
http://arjudba.blogspot.com/2008/08/how-to-monitor-alert-log-file-in-oracle.html
http://arjudba.blogspot.com/2008/08/solution-of-ora-01873-leading-precision.html
http://arjudba.blogspot.com/2008/07/literals-and-literal-types-in-oracle.html
http://arjudba.blogspot.com/2008/07/ora-01722-invalid-number.html
http://arjudba.blogspot.com/2008/07/ora-00936-missing-expression.html
http://arjudba.blogspot.com/2008/07/ora-01756-quoted-string-not-properly.html
http://arjudba.blogspot.com/2008/07/pls-00428-into-clause-is-expected-in.html
http://arjudba.blogspot.com/2008/07/schema-object-naming-rules.html
http://arjudba.blogspot.com/2008/06/datetime-and-interval-datatypes.html
http://arjudba.blogspot.com/2008/06/large-object-lob-datatypes-with-example.html
http://arjudba.blogspot.com/2008/06/history-of-sql.html
http://arjudba.blogspot.com/2008/06/what-is-sql.html
Saturday, July 2, 2011
Hash map exception in java ClassCastException
Hash map exception in java ClassCastException
On execution of the code, the code show you an exception indicating an string cannot be converted into double.
PROGRAM
import java.util.*;
import java.util.Iterator;
public class Hashmapexception {
public static void main(String[] args) {
HashMap hashMap = new HashMap();
hashMap.put("ABS", new Double(3434.34));
hashMap.put("ABD", new Double(123.22));
hashMap.put("cccc", "jdshgjhs");
Set set = hashMap.entrySet();
Iterator i = set.iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry) i.next();
System.out.println(me.getKey() + " : " + me.getValue());
}
double balance = ((Double) hashMap.get("cccc")).doubleValue();
hashMap.put("cccc", new Double(balance + 1000));
System.out.println("balance : " + hashMap.get("cccc"));
}
}
OUTPUT
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at Hashmapexception.main(Hashmapexception.java:20)
Java Result: 1
Hash table exception in java java.util.NoSuchElementException Hashtable Enumerator
Hash table exception in java java.util.NoSuchElementException Hashtable Enumerator
import java.util.*;
import java.util.Hashtable;
import java.util.Enumeration;
public class HashTableException {
public static void main(String args[]) {
try {
Hashtable hashtable = new Hashtable();
hashtable.put("Girish", new Integer(1));
hashtable.put("Tewari", new Integer(2));
Integer one = (Integer) hashtable.get("One");
System.out.println("Elements in the Hashtable");
Enumeration e = hashtable.keys();
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
System.out.println(e.nextElement());
System.out.println(e.nextElement());
}
} catch (Exception ex) {
System.out.println
("Exception generated by hash table is "+ex.getMessage());
}
}
}
import java.util.*;
import java.util.Hashtable;
import java.util.Enumeration;
public class HashTableException {
public static void main(String args[]) {
try {
Hashtable hashtable = new Hashtable();
hashtable.put("Girish", new Integer(1));
hashtable.put("Tewari", new Integer(2));
Integer one = (Integer) hashtable.get("One");
System.out.println("Elements in the Hashtable");
Enumeration e = hashtable.keys();
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
System.out.println(e.nextElement());
System.out.println(e.nextElement());
}
} catch (Exception ex) {
System.out.println
("Exception generated by hash table is "+ex.getMessage());
}
}
}
OUTPUT
java.util.NoSuchElementException: Hashtable Enumerator
What is a NoClassDefFoundError in java exception Reason and when will occur the error
What is a NoClassDefFoundError in java exception Reason and when will occur the error
NoClassDefFoundError is another common exception thrown by the class loader during the loading phase. The JVM specification defines NoClassDefFoundError as follows:
Thrown if the Java virtual machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
Essentially, this means that a NoClassDefFoundError is thrown as a result of a unsuccessful implicit class load.
Note :
Another One Reason occure the “ NoClassDefFoundError”
Our Server have the jre 1.5 But you local system jre 1.6
Your local system class file generated by jdk 1.6 . that file uploed to the server . Then show the error. Because server have jdk 1.5. So version one problem.
Example Error Code
500 Servlet Exception
java.lang.NoClassDefFoundError: yellowpages/helper/AllCategoryDAO
at yellowpages.action.AllCategoryAction.execute(AllCategoryAction.java:27)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:413)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:225)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:435)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:602)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:690)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:612)
at java.lang.Thread.run(Thread.java:619)
NoClassDefFoundError is another common exception thrown by the class loader during the loading phase. The JVM specification defines NoClassDefFoundError as follows:
Thrown if the Java virtual machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
Essentially, this means that a NoClassDefFoundError is thrown as a result of a unsuccessful implicit class load.
Note :
Another One Reason occure the “ NoClassDefFoundError”
Our Server have the jre 1.5 But you local system jre 1.6
Your local system class file generated by jdk 1.6 . that file uploed to the server . Then show the error. Because server have jdk 1.5. So version one problem.
Example Error Code
500 Servlet Exception
java.lang.NoClassDefFoundError: yellowpages/helper/AllCategoryDAO
at yellowpages.action.AllCategoryAction.execute(AllCategoryAction.java:27)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:413)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:225)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:435)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:602)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:690)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:612)
at java.lang.Thread.run(Thread.java:619)
Subscribe to:
Posts (Atom)