This exception will be thrown when there are multiple JDBC drivers in the classpath and there exists some conflict among these drivers.So better remove the duplicate JDBC drivers and give a try.
This resolved our issues
Learning Java : Static Variables and Static Methods
package Learn;
import java.lang.*;
public class implementingClass {
static int count;
public implementingClass()
{
count = count+2;
}
static void increment () {
count = count+3;
}
public static void main(String[] args) {
System.out.println("Default value of count: " + count);
implementingClass.increment();
System.out.println("count: " + count);
}
}
Output
Default value of count: 0
count: 3
Static variables are not tied to any object.They will be created at the time of class loading.Static methods can be called without object instantiation.
import java.lang.*;
public class implementingClass {
static int count;
public implementingClass()
{
count = count+2;
}
static void increment () {
count = count+3;
}
public static void main(String[] args) {
System.out.println("Default value of count: " + count);
implementingClass.increment();
System.out.println("count: " + count);
}
}
Output
Default value of count: 0
count: 3
Static variables are not tied to any object.They will be created at the time of class loading.Static methods can be called without object instantiation.
Labels:
Java
Redirecting the output of System.out.println, System.err.println to a file/log file.
Sometimes you might need to redirect the output System.out.println,System.err.println to a log file.Refer the following code snippet for doing this
public static void main(String[] args) throws Exception {
ABC abc = new ABC();
PrintStream printStream;
printStream = new PrintStream(new FileOutputStream("C://javaout.log"));
System.setOut(printStream);
System.setErr(printStream);
System.out.println("I am from Out...");
System.err.println("I am from Error");
}
Now check the javaout.log in c drive
public static void main(String[] args) throws Exception {
ABC abc = new ABC();
PrintStream printStream;
printStream = new PrintStream(new FileOutputStream("C://javaout.log"));
System.setOut(printStream);
System.setErr(printStream);
System.out.println("I am from Out...");
System.err.println("I am from Error");
}
Now check the javaout.log in c drive
Redirecting exception' printStackTrace to a file
catch(Exception e){
: : :
e.printStackTrace( new PrintStream(("C://javaout.log")));
: : :
Labels:
Java,
Programming Tips
The server principal "domain\windowsuser" is not able to access the database "DATABSE" under the current security context.
The server principal "domain\windows user" is not able to access the database "DATABSE" under the current security context.
This will normally happen when ODBC Datsource in the ODBCAD32 is configured to use "With Integrated Windows Authentication" mode of authentication to the sql server.
The reason being that the domain\windows user is not added in the list of logins under the security tab of the sql server.
So the solution is to change the authentication type to "With SQL Server authentication using a login ID and password entered by the user".
Sometimes you cannot change the authentication from former to latter,especially when you login as a non-admin user.In this case you need to login with admin user and change the authentication type.
This will normally happen when ODBC Datsource in the ODBCAD32 is configured to use "With Integrated Windows Authentication" mode of authentication to the sql server.
The reason being that the domain\windows user is not added in the list of logins under the security tab of the sql server.
So the solution is to change the authentication type to "With SQL Server authentication using a login ID and password entered by the user".
Sometimes you cannot change the authentication from former to latter,especially when you login as a non-admin user.In this case you need to login with admin user and change the authentication type.
Labels:
Database,
Sql Server,
Windows
search the existence of an object in sql server 2005.
Quick way to search the existence of an object in sql server 2005.
Create a stored procedure by name 'sp_ObjectSearch' and copy the below code.Now start searching...
ex:-
sp_ObjectSearch 'Employee'
sp_ObjectSearch 'F4211' etc
USE [master]
GO
/****** Object: StoredProcedure [dbo].[sp_ObjectSearch] Script Date: 06/23/2009 05:10:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ==========================================================================================
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- ==========================================================================================
-- Script Title : sp_ObjectSearch
-- =====================================================================================
-- Description : Have you ever tried to look for an object in a
-- SQL Server instance that has hundreds of databases
-- without knowing the object's exact name and the
-- database in which it resides?
-- this proc will look for anyobject with the exisiting instance
-- that match all or part of the search string
-- =====================================================================================
-- Coder : Shaunt Khaldtiance
-- Creation Date : 02.09.2008
-- Last Modification Date :
--
-- example : exec master..sp_ObjectSearch 'user'
-- ==========================================================================================
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- ==========================================================================================
ALTER proc [dbo].[sp_ObjectSearch]
@object varchar(max)
as
declare dblist cursor for select name from sys.databases;
create table #result (DatabaseName varchar(256),TypeName varchar(256),ObjectName varchar(256))
declare @dbname varchar(max),
@cmd varchar(max)
open dblist
fetch next from dblist into @dbname
while (@@fetch_status=0)
begin
select @cmd='if exists (select * from ['+@dbname+'].sys.objects where name like ''%'+@object+'%'' )
begin
insert #result
select '''+upper(@dbname)+''' as [Database],
case type
when ''AF'' Then ''Aggregate function (CLR)''
when ''C'' Then ''CHECK constraint''
when ''D'' Then ''DEFAULT (constraint or stand-alone)''
when ''F'' Then ''FOREIGN KEY constraint''
when ''PK'' Then ''PRIMARY KEY constraint''
when ''P'' Then ''SQL stored procedure''
when ''PC'' Then ''Assembly (CLR) stored procedure''
when ''FN'' Then ''SQL scalar function''
when ''FS'' Then ''Assembly (CLR) scalar function''
when ''FT'' Then ''Assembly (CLR) table-valued function''
when ''R'' Then ''Rule (old-style, stand-alone)''
when ''RF'' Then ''Replication-filter-procedure''
when ''SN'' Then ''Synonym''
when ''SQ'' Then ''Service queue''
when ''TA'' Then ''Assembly (CLR) DML trigger''
when ''TR'' Then ''SQL DML trigger''
when ''IF'' Then ''SQL inlined table-valued function''
when ''TF'' Then ''SQL table-valued-function''
when ''U'' Then ''Table (user-defined)''
when ''UQ'' Then ''UNIQUE constraint''
when ''V'' Then ''View''
when ''X'' Then ''Extended stored procedure''
when ''IT'' Then ''Internal table''
end As Type
,Name as [Object Name] from ['+@dbname+'].sys.objects
where name like ''%'+@object+'%''
end '
exec (@cmd)
fetch next from dblist into @dbname
end
close dblist
deallocate dblist
select * from #result order by DatabaseName, TypeName, ObjectName
drop table #result
Create a stored procedure by name 'sp_ObjectSearch' and copy the below code.Now start searching...
ex:-
sp_ObjectSearch 'Employee'
sp_ObjectSearch 'F4211' etc
USE [master]
GO
/****** Object: StoredProcedure [dbo].[sp_ObjectSearch] Script Date: 06/23/2009 05:10:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ==========================================================================================
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- ==========================================================================================
-- Script Title : sp_ObjectSearch
-- =====================================================================================
-- Description : Have you ever tried to look for an object in a
-- SQL Server instance that has hundreds of databases
-- without knowing the object's exact name and the
-- database in which it resides?
-- this proc will look for anyobject with the exisiting instance
-- that match all or part of the search string
-- =====================================================================================
-- Coder : Shaunt Khaldtiance
-- Creation Date : 02.09.2008
-- Last Modification Date :
--
-- example : exec master..sp_ObjectSearch 'user'
-- ==========================================================================================
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- ==========================================================================================
ALTER proc [dbo].[sp_ObjectSearch]
@object varchar(max)
as
declare dblist cursor for select name from sys.databases;
create table #result (DatabaseName varchar(256),TypeName varchar(256),ObjectName varchar(256))
declare @dbname varchar(max),
@cmd varchar(max)
open dblist
fetch next from dblist into @dbname
while (@@fetch_status=0)
begin
select @cmd='if exists (select * from ['+@dbname+'].sys.objects where name like ''%'+@object+'%'' )
begin
insert #result
select '''+upper(@dbname)+''' as [Database],
case type
when ''AF'' Then ''Aggregate function (CLR)''
when ''C'' Then ''CHECK constraint''
when ''D'' Then ''DEFAULT (constraint or stand-alone)''
when ''F'' Then ''FOREIGN KEY constraint''
when ''PK'' Then ''PRIMARY KEY constraint''
when ''P'' Then ''SQL stored procedure''
when ''PC'' Then ''Assembly (CLR) stored procedure''
when ''FN'' Then ''SQL scalar function''
when ''FS'' Then ''Assembly (CLR) scalar function''
when ''FT'' Then ''Assembly (CLR) table-valued function''
when ''R'' Then ''Rule (old-style, stand-alone)''
when ''RF'' Then ''Replication-filter-procedure''
when ''SN'' Then ''Synonym''
when ''SQ'' Then ''Service queue''
when ''TA'' Then ''Assembly (CLR) DML trigger''
when ''TR'' Then ''SQL DML trigger''
when ''IF'' Then ''SQL inlined table-valued function''
when ''TF'' Then ''SQL table-valued-function''
when ''U'' Then ''Table (user-defined)''
when ''UQ'' Then ''UNIQUE constraint''
when ''V'' Then ''View''
when ''X'' Then ''Extended stored procedure''
when ''IT'' Then ''Internal table''
end As Type
,Name as [Object Name] from ['+@dbname+'].sys.objects
where name like ''%'+@object+'%''
end '
exec (@cmd)
fetch next from dblist into @dbname
end
close dblist
deallocate dblist
select * from #result order by DatabaseName, TypeName, ObjectName
drop table #result
Labels:
Database,
Sql Server,
Tools
DB2 database and SQL limits
| DB2 database and SQL limits. This information is collected from a book on DB2 database | |
| Description | Limit |
| Maximum combined length for INT, SMALLINT, CHAR, DECIMAL, DATE, TIME, and TIMESTAMP columns in a single record | 32767 bytes |
| Maximum length of a BLOB column | 2 Gigabytes -1 byte |
| Maximum length of a CHAR column | 32767 bytes |
| Maximum length of a SQL statement | 64 kilobytes |
| Maximum length of a VARCHAR column | 32767 bytes |
| Maximum length of a check constraints | 32767 bytes |
| Maximum length of a default value | 32767 bytes |
| Maximum length of a row in a table | 64 kilobytes |
| Maximum length of each column in a single index | 1024 bytes |
| Maximum number of columns in a foreign key | 8 |
| Maximum number of columns in an index | 8 |
| Maximum number of columns in a primary key | 8 |
| Maximum number of columns in a table | 256 |
| Maximum number of indices in a table | 15 |
| Maximum number of LOB locators | 256 |
| Maximum number of rows in a table | Limited by table size |
| Maximum number of statement handles per connection | 256 |
| Maximum number of tables in a data store | 65535 |
| Maximum size of a decimal | 31 digits |
| Maximum size of a literal | 32672 bytes |
| Maximum size of a table (on a 32 bit system) | 2 Gigabytes |
| Maximum year for a date value | 9999 |
| Minimum year for a date value | 0001 |
Subscribe to:
Posts (Atom)