Thursday 14 September 2017

Converting excel data into SQL insert query.

Lets suppose you have thousands of data which you need to insert in database and that data is in Excel.

you can easily convert your data into query.

1. insert a new column in your sheet.

2. write this query in the first empty column which is newly created 

here B2,C2 represent columns of your data.



Query builder:

 ="insert into employees values('"&B2&"','"&C2&"','"&D2&"','"&E2&"','"&F2&"',

'"&G2&"','"&H2&"','"&I2&"','"&J2&"','"&K2&"','"&L2&"','"&M2&"');"


3. Add coloumns which you need in your query.
4. drag down to all rows so that changes reflect for all the rows.
5. save your excel.

you have sql query of insertion.

Tuesday 22 August 2017

SQL Error: ORA-14402: updating partition key column would cause a partition change


Error:

SQL Error: ORA-14402: updating partition key column would cause a partition change
14402. 00000 -  "updating partition key column would cause a partition change"
*Cause:    An UPDATE statement attempted to change the value of a partition
           key column causing migration of the row to another partition
*Action:   Do not attempt to update a partition key column or make sure that
           the new partition key is within the range containing the old


Solution :

 ALTER TABLE <table name> ENABLE ROW MOVEMENT;


Example:

select * from part_table;

CREATE TABLE part_table (ID NUMBER)
    PARTITION BY RANGE (ID)
      (partition p0 values less than (1),
        PARTITION p1 VALUES LESS THAN (MAXVALUE));

insert into part_table values (0);

UPDATE part_table SET ID = 2;

when you try to update this partition column it gives you ORA-14402.

By default ROW MOVEMENT is DISABLE.

you should alter your table to enable the row movement.

ALTER TABLE part_table ENABLE ROW MOVEMENT;





Monday 26 June 2017

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()



Exception:
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)


Solution :


This error usual means that you have a both a JAX-RS 1 and JAX-RS 2 jar on the classpath. 

Jersey 2 uses JAX-RS 2 (javax.ws.rs-api-2.0.1.jar), but if you have the jsr311-api.jar also, which is JAX-RS 1, there is a javax.ws.rs.core.Application in each jar.

But the jsr311-api Application doesn't have the method getProperties() (hence NoSuchMethodError).

So just exclude these dependencies manually or by eclipse dependency hierarchy feature :

1. Open POM
2. Open dependency hierarchy tab in bottom.
3. search for jsr and exclude all jsr dependencies.







Failed to instantiate [org.apache.cxf.endpoint.Server]: Factory method 'jaxRsServer' threw exception;



Exception:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.cxf.endpoint.Server]: Factory method 'jaxRsServer' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.isCglibProxyClass(Ljava/lang/Class;)Z
 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
 at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
 ... 28 more
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.isCglibProxyClass(Ljava/lang/Class;)Z
 at org.apache.cxf.common.util.SpringAopClassHelper.getRealClassInternal(SpringAopClassHelper.java:85)
 at org.apache.cxf.common.util.ClassHelper.getRealClass(ClassHelper.java:55)
 at org.apache.cxf.jaxrs.JAXRSServiceFactoryBean.setResourceClassesFromBeans(JAXRSServiceFactoryBean.java:218)
 at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBeans(JAXRSServerFactoryBean.java:302)
 at com.example.config.AppConfig.jaxRsServer(AppConfig.java:29)
 at com.example.config.AppConfig$$EnhancerBySpringCGLIB$$67f4649c.CGLIB$jaxRsServer$3(<generated>)
 at com.example.config.AppConfig$$EnhancerBySpringCGLIB$$67f4649c$$FastClassBySpringCGLIB$$ae89a288.invoke(<generated>)
 at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
 at com.example.config.AppConfig$$EnhancerBySpringCGLIB$$67f4649c.jaxRsServer(<generated>)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:483)
 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(Simpl




 To solve this issue update your versions of below dependencies:

<org.apache.cxf.version>3.1.0</org.apache.cxf.version>

<org.springframework.version>4.3.5.RELEASE</org.springframework.version>

this will resolve the issue,


Thursday 22 June 2017

Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.

I was hitting the same problem when working with Apache tomcat . .


Solution Steps :


  1. Backup your pom.xml somewhere.
  2. Go to your pom.xml and on the bottom tab and click "Dependency Hierarchy" tab. 
  3. From there search for log4j-over-slf4j. 
  4. Exclude all instances of this dependency (right click on the instance and "Exclude Maven Artifact"). After you have no more log4j-over-slf4j appearing save your POM and try to run the program. 
  5. If it still doesn't work then undo the changes you just made and exclude all instances of slf4j-log4j12.


Hopes this will resolve your problem

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;

Problem :

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;


Solution :

getContextPath() was added with Servlet 2.5, does your version of Jetty supports that ? 


Might also want to check that you do not have some older or duplicate version of j2ee around.

Indicates that Jetty 6.1.x supports Servlet 2.5 , make sure you don't have a pre-2.5 servlet version around. If this gets loaded before the 2.5 version, the entire classpath sees only Servlet 2.0 API (the 2.5 doesn't even gets loaded).

so exclude it from the maven pom.xml


Exclusion entry
 <exclusion>
           <artifactId>servlet-api</artifactId>
           <groupId>javax.servlet</groupId>
  </exclusion>

Monday 12 June 2017

Debug javascript.

Guide to Debug your java script files in google Chrome.



Ways to find debug console in chrome.

2. press F12 or inspect element

Below window will open up which contains various tabs.
 
Tab Details:

Elements: it shows HTML part of your page.
console : in case you want to run some statements.
sources : all your JavaScript files.
Network : shows all your Ajax and load requests.
Performance: you can monitor your page performance


How to debug:

To debug any javascript file just search your file by using ctrl+O or select your file from the left panel of your browser window.

To add debug point just click on row number as shown in the image below.


Now perform any operations on you webpage. Here I'm selecting value from the dropdown.






As soon as you select any value from the drop down. your request goes for processing and your request stop on debug point.



For this request in network tab there is an entry for it. which shows data retrieve from the request for more information you can select request header,response and preview tab.

After successful hit of the request your request will enter in the success part of your ajax request.




If you want to change and explore more values you can go to console tab.

if you want to change values of HTML element then go to element tab where you can change style of the page and can see change in real time.





Wednesday 5 April 2017

HTTP Status 405 – HTTP method GET is not supported by this URL

Problem :

HTTP Status 405 - HTTP method GET is not supported by this URL


Solution :
This is always caused by following two reasons
1) You do not have a valid doGet() method, when you type the servlet’s path
in address bar directly, the web container like Tomcat will try to invoke the
doGet() method.
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException{
 
}
2) You made a HTTP post request from a HTML form, but you do not
have a doPost() method to handle it. The doGet() cannot handle the “Post” request.


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException{
 
}


Example of wrong doGet() and doPost() method

protected void doPost(HttpServletRequest request, 
                      HttpServletResponse response, PrintWriter Out){
}


These two methods get() and post() must have only 
2 parameters otherwise it will not be called.


Sunday 2 April 2017

Display data from Json in Angularjs

Problem :

I'm using the following code, witch includes the app.js, page.html and data.json The app.js seems to work fine, but the view (page.html) isn't display any data..


HTML :

<div ng-controller="tablesController" style="padding-left: 15px">
 <div class="ng-scope">
  <div class="row ng-scope"></div>
 </div>
</div>

<div>
 <md-list flex> <md-list-item class="md-3-line"
  ng-repeat="item in hotelList" ng-click="null"> <img
  ng-src="{{item.hotel_data_node.img_selected.thumb.l}}?{{$index}}"
  class="md-avatar" alt="" />
 <div class="md-list-item-text" layout="column">
  <h3>{{item.hotel_data_node.name}}</h3>
  Rating :
  <h4>{{item.hotel_data_node.extra.gir_data.hotel_rating}}</h4>
 </div>
 </md-list-item> </md-list>
</div>


JSON:
{
    "data": {
        "1061221765445223317": {
            "hotel_geo_node": {
                "name": "Payal Hotel Panvel", 
                "tags": {
                    "property_budget_category": "test"
                }
}
}




JSON:
{
 "data": {
  "1061221765445223317": {
   "hotel_geo_node": {
    "name": "PayalHotelPanvel", 
                                "tags": { "property_budget_category": "test"
   }
  }
 }
}


Solution :

You are missing your view from your controller, you have to include your view into your controller.

i.e 


HTML :

<div ng-controller="tablesController" style="padding-left: 15px">
 <div class="ng-scope">
  <div class="row ng-scope"></div>
 </div>
</div>

//included in CONTROLLER now
<md-list flex> <md-list-item class="md-3-line"
 ng-repeat="item in hotelList" ng-click="null"> <img
 ng-src="{{item.hotel_data_node.img_selected.thumb.l}}?{{$index}}"
 class="md-avatar" alt="" />
<div class="md-list-item-text" layout="column">
 <h3>{{item.hotel_data_node.name}}</h3>
 Rating :
 <h4>{{item.hotel_data_node.extra.gir_data.hotel_rating}}</h4>
</div>
</md-list-item> </md-list>
</div>
</div>



Tuesday 21 March 2017

ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA


Solution :

Try changing your ORA properties.

from this :
ORA11gR23 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS =

        (PROTOCOL = TCP)

        (HOST = orasrv-alanb-lx06)

        (PORT = 1521)

      )

      (CONNECT_DATA =

        (SERVER = DEDICATED)

        (SERVICE_NAME = ORA11gR23)

      )

    )

  )
  

To this:
ORA11gR23 =

  (DESCRIPTION =

      (ADDRESS =

        (PROTOCOL = TCP)

        (HOST = orasrv-alanb-lx06)

        (PORT = 1521)

      )

      (CONNECT_DATA =

        (SERVER = DEDICATED)

        (SERVICE_NAME = ORA11gR23)

      )

  )
  
your SERVICE_NAME = ORA11gR23 should match the name you have given before description.



Wednesday 8 March 2017

Unknown Provider : $locationProviderProvider <- $locationProvider

Error :

Unknown Provider : $locationProviderProvider <- $locationProvider <- myCtrl 

also got this error.

You're allowed to inject a $location into a controller, but not a $locationProvider.

Instead, the $locationProvider can be injected into a config method:


Solution :
var app = angular.module("myApp", []);

app.config(function($locationProvider) {
  $locationProvider.html5Mode(true);
});

app.controller("myCtrl", function($location) {
  $location.path("/some/path");
});


And since I made this additional mistake: it's not just that you should add an app.config bit, but also remember to remove $locationProvider from the controller arguments, or you'll keep getting this error.


Also you have to add <base> tag in your html file <head> tag



 <base href="/myDemoProject/">

Wednesday 1 March 2017

Angular alert will not display after being closed

Problem :

when you try to close the angular success and error pop up using manullay or using alert('close') event.


HTML
  <div class="cacheSuccessMessage alert alert-success alert-dismissable-success">
       <span class="cacheMessageHeader"><strong></strong></span>
        <div class="cacheMessageDetails"></div>
  </div>


JS:
$(".alert-dismissable-success").fadeTo(4000, 500).slideUp(500,
 function() {
 $(".alert-dismissable-success").alert('close');
})


so when you fire event of close Data-dismiss completely removes the element. 


Solution : 

 Use jQuery's .hide() or angular hide method instead to hide error.
and modify you HTML and JS as 


HTML
  <div class="cacheSuccessMessage alert alert-success">
           <span class="cacheMessageHeader"></span>
            <div class="cacheMessageDetails"></div>
  </div>

JS:
$(".cacheSuccessMessage").fadeTo(4000, 500).slideUp(500,
 function() {
 $(".cacheSuccessMessage").hide();
})

Wednesday 18 January 2017

Tail Logger for Big .log files - Log Expert

While development you might encountered problem of logging big files

for logging every time we have to either load  .log file in notepad on in any other software.

here is a software which smartly handle all your log files and it follows the tail


Summary of features:

  • Tail mode
  • MDI-Interface with Tabs
  • Search function (including RegEx)
  • Bookmarks
  • A very flexible filter view
  • Highlighting lines via search criteria
  • Columnizers: This means splitting log lines into columns for some well defined logfile formats
  • Unicode support
  • log4j XML file support
  • 3rd party plugin support
  • SFTP support (loading files directly from SFTP)
  • Plugin API for more log file data sources


You can download it from here.

http://logexpert.codeplex.com/

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...