Showing posts with the label java

DmL command || Sql Tutorial -7

DML Command Insert Command Its used to insert the record into table example- Command for inserting single record insert into <table name> values(value1, value2...) Command for inserting multiple command at a time insert into <table name> values(&col1, &col2...., &coln); whenever you enter query like this it will ask you to like this - enter a value for column1- value1.. and then hit enter  - enter a value for column2- value2.. and then hit enter - enter a value for column3- value3.. and then hit enter Now it will show 1 row created  if you want to create more record use / and hit enter SQL> /   hit enter // it will Execute most recent query again //this will so again and so on... - enter a value for column1- value1..  and then hit enter  - enter a value for column2- value2..  and then hit enter - enter a value for column3- value3..  and then hit enter // if you will miss any value here that will be inserted as NULL value Update command Used to upda

Difference Between pluck and collect

Difference Between pluck and collect Pluck Pluck takes less time then collect because when we use collect we have to execute two queries for collecting record Example-  When have a user table and we have to collect all id's User.all.collect(&:id) // when we use collect we are running two query internally                                        first user.all and then we collect id's User.pluck(:id) // Here we are running only one query that's why it take less time Pluck also take more than one parameter at a time but collect can not Example- user.pluck(:id, :name) // it will return array of id and name user.collect(&:id , &:name) // it will give an error

DDL command || Sql Tutorial -6

DDL Command CREATE Command It is used to create any data base object like tables, views, indexes, sequences, synonyms , users, functions, procedures, triggers, packages and so on. HOW TO CREATE A TABLE?            syn: CREATE TABLE <table_name>             (              <colname1> DATATYPE (size),               <colname2> DATATYPE (size),                : : : :,                : : : :,             ); INSERT Command This command is used for inserting new records into the tables          Syntax:           INSERT INTO <table_name>[(col1, col2,...., col n)]           VALUES(val1, val2,.....,val n);                  NOTE:  i) If number of columns in the table and number of values inserting in to the table      are equal, then no need to specify column names while inserting records.            ii) Char, Varchar2 and date type values should be enclosed in Single Quotes.            iii) If Number of inserting values are less than the

DATATYPES in sql || Sql Tutorial -5

DATATYPES IN SQL  The data type represents the type of data to be entered into a column and Db engine can assign memory for thevalue entered into the column. There are 5 types of DataType in sql. String DataTypes Numeric DataTypes Date Datatypes Binary DataTypes LOB--Large Objects String Data Types These data types support sequence of character, digits and any symbol from keyboard. CHAR(size) It is used to store fixed length character strings. By default the size is 1 character, and max size is 2000 chars orbytes. Ex: student_id, email, address and so on VARCHAR2(size) It is used to store variable length character strings. No default size. we should specify size and max size is 4000 chars /bytes. Ex: emp names, addresses, descriptions, city names. LONG It is used to store variable length char data(similar to varchar2 data type) but max size is 2 GB NOTE: Only one long type column is allowed per a table. 1) NUMBER(Precision, [Scale])    It is used to store numb

Features of Sql * Plus

Features of Sql * Plus At a time only one query is allowed to execute Sql queries are not case sensitive Each query is terminated with ; ( semi colon ) SQL commands are ANSI standard ( American National standard institute )

What is sql definition(Structured query language). Sql Tutorial -2

Structured query language It is a collection of pre defined commands and constructs with syntactical rules. 1. Sql is a client tool to interact with ORACLE DB /any DB 2. Sql is to be installed in to the system whenever we have installed the db software. 3. Client [Technical] requests should be submitted in the form of "Queries". 4. Queries are executed by SQL STMT EXECUTOR ( Oracle Db Engine ) 5. Queries are executed against database and output will be displayed on the Sql * plus window.

Array of string arguments in Java || string args[]

public static void main( String []args ). This string args is used to taking input from console,when we access the file and give some input value. suppose our filename is And the className, which has Main method is ABC. To compile this we Run command- javac After the compilation this will generate class code that is- ABC.class When we run this using- java ABC “ if here we pass some value this value will go to the args ”. so thats why we use it.

HTTP status 404 in servlet programming in Java ( Apache Tomcat 7)? || http 404

Error 404 is generate when, Database connection is failed. Incorrect query parameters. Incorrect dB name. Mismatch swapping between webpages.

Type error “Java.util.Scanner.nosuchelementexception” || Exception || nosuchelementexception

This exception extends the  RuntimeException  class and thus, belongs to those exceptions that can be thrown during the operation of the  Java Virtual Machine (JVM) . It is an unchecked exception and thus, it does not need to be declared in a method’s or a constructor’s throws clause. The NoSuchElementException in Java The  NoSuchElementException   can be thrown by the following methods : Enumeration::nextElement() NamingEnumeration::next() StringTokenizer::nextElement() Iterator::next() All the aforementioned methods try to return the next element of an  enumeration  and throw that exception, in order to indicate that no more elements exist. example- import   java . util . HashSet ; import   java . util . Hashtable ; import   java . util . Set ; import   java . util . StringTokenizer ; public   class   NoSuchElementExceptionExample { public   static   void   main ( String [] args ) { Set sampleSet = new   HashSet (); Hashtable sampleTable =

Is-a and Has-a RelationShip

In java or other object oriented programming language is-a and has-a are two type of relationship under the concepts of inheritance. suppose we have three class Car. subaru. engine. subaru is a car — its a is-a  relationship  between  class  subaru and  class  car. car has a engine — its a has-a  relationship  between  class  car and  class  engine.

Java class Name main

We can put the class name main their is no  compilation error or run time error . class main { public static void main(String []args) { // do your code } } now suppose our filename is and now we are compiling it with command prompt- compiling- javac Run- java main

How can I create thread array?

int [] testscore = new int[4];  //create an array of size 4. similarly we create thread array, Thread threads = new Thread[5]; // no thread objects created!   one   Thread array created Remember that, we are not creating a thread instance ,but rather a single Thread array object.

What does the "String[ ] args" in a Java main method actually mean?

in Java  args   contains the supplied  command-line arguments  as an array of  String   objects. In other words, if you run your program as  java MyProgram one two  then  args will contain  [ "one" , "two" ] . If you wanted to output the contents of  args , you can just loop through them like this... public class ArgumentExample { public static void main ( String [] args ) { for ( int i = 0 ; i < args . length ; i ++) { System . out . println ( args [ i ]); } } }

my input a=12, but how do I print this in 3 digits?

There are many ways to do this. I am using the simplest way to print two digit number in three digit number. import java . util . Scanner ; class Digit { public static void main ( String [] args ) { Scanner sc = new Scanner ( System . in ); System . out . println ( "please enter any two digit number:" ); int n = sc . nextInt (); int k = 0 ; if ( n > 9 && n < 100 ) { k = n * 10 ; } else { System . out . println ( "please enter any two digit number:" ); } System . out . println ( "you entered " + n + " and three digit output of this number is " + k ); } Read More