Hi,
Here is the code to get the URL parts using Javascript.
1) How to get the path name
var pathname= window.location.pathname;
alert( " Pathname "+ pathname );
2) How to get the hostname
var hostname = window.location.host;
alert( hostname);
3) How to get the complete URL
var URL = window.location;
alert("URL "+URL);
4) How to get the URL with out parameters
var URLWithOutPrameters = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
alert(URLWithOutPrameters );
5) How to get the Protocal in the URL.
var protocal = window.location.protocol;
alert( " protocal "+ protocal);
5) How to get the parameters in the URL
var name = "tagName"; // We can place any name , the name should contain in the URL.
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results != null )
alert( results[1]); // will display the value of the name (key value pair) ,
}
Wednesday, September 9, 2009
Thursday, September 3, 2009
MYSQL Vs Oracle
Hi,
Here I found some differances in MySQL vs Oracle
1) dual table ( in oracle we need to specify the dual table , but in MYSQL , we need not..)
2) MySQL only supports primitive data types, DATE, NUMBER and STRING and TIME.
3) MySQL supports more types of tables than Oracle, including MyISAM, MERGE, ISAM, innoDB, BDB and HEAP
4) In oracle we use "" for Concatenate strings, but in mysql , we have a function called "CONCAT("String1", "String2") "
Here I found some differances in MySQL vs Oracle
1) dual table ( in oracle we need to specify the dual table , but in MYSQL , we need not..)
2) MySQL only supports primitive data types, DATE, NUMBER and STRING and TIME.
3) MySQL supports more types of tables than Oracle, including MyISAM, MERGE, ISAM, innoDB, BDB and HEAP
4) In oracle we use "" for Concatenate strings, but in mysql , we have a function called "CONCAT("String1", "String2") "
Wednesday, September 2, 2009
MYSQL Procedures
Hi,
Here is the sample of the creating the procedures & excuting the procedures.
Creating Procedure:
CREATE PROCEDURE appl_osmp.createTest(IN testName VARCHAR(20), IN ComponentIDs TEXT )
BEGIN
DECLARE TagID INT DEFAULT 1;
INSERT INTO TEST (name) VALUES (testName);
END
Droping procedure :
drop procedure createTest;
Call the procedure:
call createTest("tom5","16395,16722,17175,16999");
Here is the sample of the creating the procedures & excuting the procedures.
Creating Procedure:
CREATE PROCEDURE appl_osmp.createTest(IN testName VARCHAR(20), IN ComponentIDs TEXT )
BEGIN
DECLARE TagID INT DEFAULT 1;
INSERT INTO TEST (name) VALUES (testName);
END
Droping procedure :
drop procedure createTest;
Call the procedure:
call createTest("tom5","16395,16722,17175,16999");
MYSQL
Hi,
Here is MYSQL Query to find
1) Number of occurance of a substring in a string.
SELECT length(" '123' ,'234','345' ")-length(REPLACE(" '123' ,'234','345' ")-, ',' , '' )) into no_of_commas;
Out put : 2
2) Equilvalent to dbms_output.put_line in MYSQL is
select "some smaple text" ;
3) To view the SP in the console.
SHOW CREATE PROCEDURE
Here is MYSQL Query to find
1) Number of occurance of a substring in a string.
SELECT length(" '123' ,'234','345' ")-length(REPLACE(" '123' ,'234','345' ")-, ',' , '' )) into no_of_commas;
Out put : 2
2) Equilvalent to dbms_output.put_line in MYSQL is
select "some smaple text" ;
3) To view the SP in the console.
SHOW CREATE PROCEDURE
Monday, August 31, 2009
Multi select transfer using JQuery
JQuery is very good GUI tool
They are many components which can be easily developed by JQuery.
1) Easy Multi Select Transfer from one text box to other can be done ealiy in JQuery.
$().ready(function() {
$('#add').click(function() {
return !$('#select1 option:selected').remove().appendTo('#select2');
});
$('#remove').click(function() {
return !$('#select2 option:selected').remove().appendTo('#select1');
});
});
2) How to find the length of the selected options in the Multi selection
var options = jQuery("#select2 option:selected");
var length = options.length;
They are many components which can be easily developed by JQuery.
1) Easy Multi Select Transfer from one text box to other can be done ealiy in JQuery.
$().ready(function() {
$('#add').click(function() {
return !$('#select1 option:selected').remove().appendTo('#select2');
});
$('#remove').click(function() {
return !$('#select2 option:selected').remove().appendTo('#select1');
});
});
2) How to find the length of the selected options in the Multi selection
var options = jQuery("#select2 option:selected");
var length = options.length;
Friday, August 28, 2009
Eclipse DB pulgins
Hi,
I have observed few things in Ecplise Gynamade
when we run stored procedure in Eclipse, It will give syntax error, the same stored procedure when excuted using in the Toad or DBViusalizer , it works perfectly
Example :
CREATE PROCEDURE TestProcedure(IN parameter1 VARCHAR(4), IN parameter2 TEXT)
BEGIN
DECLARE p1 INT DEFAULT 1;
END
when we excute the same procedure using Ecplise, we get the syntax error,
When we excute the same procedure using DBVisualizer, It works fine.
Solution :
So, Don't waste time on excuting the stored procedure in Eclipse. :-)
Regards,
DeepthiMahesh.
I have observed few things in Ecplise Gynamade
when we run stored procedure in Eclipse, It will give syntax error, the same stored procedure when excuted using in the Toad or DBViusalizer , it works perfectly
Example :
CREATE PROCEDURE TestProcedure(IN parameter1 VARCHAR(4), IN parameter2 TEXT)
BEGIN
DECLARE p1 INT DEFAULT 1;
END
when we excute the same procedure using Ecplise, we get the syntax error,
When we excute the same procedure using DBVisualizer, It works fine.
Solution :
So, Don't waste time on excuting the stored procedure in Eclipse. :-)
Regards,
DeepthiMahesh.
Thursday, August 27, 2009
Java - Hibernate - MYSQL
Hi,
In this blog, I want to share my experience when I am using hibernate
Hibernate is very good framework which makes developer work very easy, but when we are doing some stuff like calling some stored procedures etc, we will face some issues
I have listed out some issues which I faced.
This we can do in two ways
1) Normal JDBC call.
Code:
Connection con = getSession().connection();
String CompIDList = compList.toString();
java.sql.CallableStatement st = con.prepareCall(" { CALL Test (?, ?) } ");
st.setString("tagName", tag.getName());
st.setString("comList",compList);
st.execute();
The issuses when we are using the above method.
When we don't have proper premission on the server. we will face the following issuses
Error :
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:948)
at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1255)
at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3640)
at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:506)
at com.mysql.jdbc.CallableStatement.(CallableStatement.java:401)
at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4072)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4146)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
Sloution :
Just the premissions of the user to admin.
or
provide the username & password with admin premissions.
2) Using the hibernate
code :
Query query = getSession().getNamedQuery("createTagging");
query.setParameter(0, tag.getName() );
query.setParameter(1, compList );
System.out.println("TagDAO.createTag() .... "+query);
query.executeUpdate();
Error :
4:54:01,978 ERROR hibernate.TagDAO:182 - save failed
java.lang.IllegalArgumentException: callable not yet supported for native queries
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:147)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
Solution:
Update the hibernate jars with latest version.
In this blog, I want to share my experience when I am using hibernate
Hibernate is very good framework which makes developer work very easy, but when we are doing some stuff like calling some stored procedures etc, we will face some issues
I have listed out some issues which I faced.
This we can do in two ways
1) Normal JDBC call.
Code:
Connection con = getSession().connection();
String CompIDList = compList.toString();
java.sql.CallableStatement st = con.prepareCall(" { CALL Test (?, ?) } ");
st.setString("tagName", tag.getName());
st.setString("comList",compList);
st.execute();
The issuses when we are using the above method.
When we don't have proper premission on the server. we will face the following issuses
Error :
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:948)
at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1255)
at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3640)
at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:506)
at com.mysql.jdbc.CallableStatement.
at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4072)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4146)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
Sloution :
Just the premissions of the user to admin.
or
provide the username & password with admin premissions.
2) Using the hibernate
code :
Query query = getSession().getNamedQuery("createTagging");
query.setParameter(0, tag.getName() );
query.setParameter(1, compList );
System.out.println("TagDAO.createTag() .... "+query);
query.executeUpdate();
Error :
4:54:01,978 ERROR hibernate.TagDAO:182 - save failed
java.lang.IllegalArgumentException: callable not yet supported for native queries
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:147)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
Solution:
Update the hibernate jars with latest version.
Subscribe to:
Posts (Atom)