Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Thursday, March 22, 2012

Connection Pool and MSSql driver

Hi all,
I'm trying to build an application using MSSQL Server and Connection pool.
At my server.xml file I have:
<Context path="/sample" docBase="C:/myprojects/sample" reloadable="true" >
<Resource name="jdbc/StrutsDemoDS" auth="Container"
type="javax.sql.DataSource" scope="Shareable"/>
<ResourceParams name="jdbc/StrutsDemoDS">
<parameter>
<name>factory</name><value>org.apache.commons.dbcp.BasicDataSourc eFactory</value></parameter>
<parameter><name>driverClassName</name><value>com.microsoft.jdbc.sqlserver.SQLServer Driver</value></parameter>
<parameter><name>url</name><value>jdbc:microsoft:sqlserver://myserver:1433</value></parameter>
<parameter><name>username</name><value>sa</value></parameter>
<parameter><name>password</name><value>passwd</value></parameter>
<parameter><name>maxActive</name><value>20</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>
<parameter><name>maxWait</name><value>100</value></parameter>
</ResourceParams>
</Context>
In my class, I have:
protected static DataSource dataSource;
protected Connection getConnection() throws SQLException {
InitialContext ic = new InitialContext();
dataSource = (DataSource)
ic.lookup("java:comp/env/jdbc/StrutsDemoDS");
Connection conn = null;
try {
conn = dataSource.getConnection(); // The error happens at this
line
}
catch (SQLException e) {
throw e;
}
return conn;
}
I can't get successful my connection. Can anyone tell me why?
Thanks.
Lorena
Lorena,
What is the error you're getting? Are you sure the lookup is successful?
If you write a simple class that doesn't use jndi but instead uses
DriverManager, Connection, and the normal db access stuff, with the
connectstring you're passing, can you connect?
Marc
"Lorena" <Lorena@.discussions.microsoft.com> wrote in message
news:E2508C07-F91E-40C2-BF64-34B7E8C23F58@.microsoft.com...
> Hi all,
> I'm trying to build an application using MSSQL Server and Connection pool.
> At my server.xml file I have:
> <Context path="/sample" docBase="C:/myprojects/sample" reloadable="true" >
> <Resource name="jdbc/StrutsDemoDS" auth="Container"
> type="javax.sql.DataSource" scope="Shareable"/>
> <ResourceParams name="jdbc/StrutsDemoDS">
> <parameter>
> <name>factory</name><value>org.apache.commons.dbcp.BasicDataSourc eFactory</value></parameter>
> <parameter><name>driverClassName</name><value>com.microsoft.jdbc.sqlserver.SQLServer Driver</value></parameter>
> <parameter><name>url</name><value>jdbc:microsoft:sqlserver://myserver:1433</value></parameter>
> <parameter><name>username</name><value>sa</value></parameter>
> <parameter><name>password</name><value>passwd</value></parameter>
> <parameter><name>maxActive</name><value>20</value></parameter>
> <parameter><name>maxIdle</name><value>10</value></parameter>
> <parameter><name>maxWait</name><value>100</value></parameter>
> </ResourceParams>
> </Context>
> In my class, I have:
> protected static DataSource dataSource;
> protected Connection getConnection() throws SQLException {
> InitialContext ic = new InitialContext();
> dataSource = (DataSource)
> ic.lookup("java:comp/env/jdbc/StrutsDemoDS");
> Connection conn = null;
> try {
> conn = dataSource.getConnection(); // The error happens at
> this
> line
> }
> catch (SQLException e) {
> throw e;
> }
> return conn;
> }
> I can't get successful my connection. Can anyone tell me why?
> Thanks.
> Lorena

Sunday, March 11, 2012

Connection is busy ...

Hi all,

I use VC++ 6 and MFC, with SQL Express 2005.

source code sample :

CRecordset *rec1 = new CRecordset(machine->pDB);
rec1->Open(...,szSQL,...);
while(!rec1->IsEOF())
{
CDBVariant var1,var2;
rec1->GetFieldValue("COL1",var1);
rec1->GetFieldValue("COL2",var2);

int val1 = GET_INDEX(var1);
int val2 = GET_INDEX(var2);
var1.Clear();
var2.Clear();

CRecordset *rec2 = new CRecordset(machine->pDB);
szSQL.Format("SELECT COL3,COL4 FROM TB1 WHERE COL3 = %i AND COL4 = %i",val1,val2);
rec2->Open(...,szSQL,...);
while(rec2->IsEOF())
{
//Something
rec2->MoveNext();
}
rec2->Close();
delete rec2;
rec1->MoveNext();
}
rec1->Close();
delete rec1;
On the red line, i catch a CBDException "Connection is busy with results for another command"

I think, I can't use the same database connection with severals Recordset simultaneous but why and it's normal, what is wrong in my source code or in the database server configuration ?

Please help me ...

By default, the connection you made to server doesn't support MARS(Multiple Active ResultSet). Which means, that you can only open one result set against server per connection. You need to close one result set before you open another result set.

But you can make this work my turning on MARS. You can refer to the following blog for information on how to turn on MARS in your connection string. Please note that you need to use SNAC to be able to use MARS feature.

http://blogs.msdn.com/dataaccess/archive/2005/08/02/446894.aspx

Please let me know if you need more help on this.

Connection is busy ...

Hi all,

I use VC++ 6 and MFC, with SQL Express 2005.

source code sample :

CRecordset *rec1 = new CRecordset(machine->pDB);
rec1->Open(...,szSQL,...);
while(!rec1->IsEOF())
{
CDBVariant var1,var2;
rec1->GetFieldValue("COL1",var1);
rec1->GetFieldValue("COL2",var2);

int val1 = GET_INDEX(var1);
int val2 = GET_INDEX(var2);
var1.Clear();
var2.Clear();

CRecordset *rec2 = new CRecordset(machine->pDB);
szSQL.Format("SELECT COL3,COL4 FROM TB1 WHERE COL3 = %i AND COL4 = %i",val1,val2);
rec2->Open(...,szSQL,...);
while(rec2->IsEOF())
{
//Something
rec2->MoveNext();
}
rec2->Close();
delete rec2;
rec1->MoveNext();
}
rec1->Close();
delete rec1;
On the red line, i catch a CBDException "Connection is busy with results for another command"

I think, I can't use the same database connection with severals Recordset simultaneous but why and it's normal, what is wrong in my source code or in the database server configuration ?

Please help me ...

By default, the connection you made to server doesn't support MARS(Multiple Active ResultSet). Which means, that you can only open one result set against server per connection. You need to close one result set before you open another result set.

But you can make this work my turning on MARS. You can refer to the following blog for information on how to turn on MARS in your connection string. Please note that you need to use SNAC to be able to use MARS feature.

http://blogs.msdn.com/dataaccess/archive/2005/08/02/446894.aspx

Please let me know if you need more help on this.

Wednesday, March 7, 2012

Connection Error when trying to run MDX-queries

To learn MDX (on SQL Server 2005 dev edition) I decided to put up some sample cubes and run MDX-queries from SQL Server Management Studio. When processing the cube in BI Studio I get the following error:

"The datasource , 'Adventure Works DW', contains an ImpersonationMode that that is not supported for processing operations."

Fair enough, then I change the impersonationmode in the datasource to service account. It all processes/deploys well and I can browse the cube in BI Studio. Off to Management studio to run some mdx-queries. Here however I get the error:

"Error (Data mining): Either the user, ######, does not have permission to access the referenced mining model, Analysis Services Tutorial, or the object does not exist."

That is of course due to me using the current user credentials for the query. So I try to change the current connection in management studio but the helpbutton informs me that as of now only windowsauthentication can be used for analysis services. So the only connectionway I can use from here is the only one not supported when processing?! This must mean I've done some childishly simple newbiemistake and I would be very grateful if you pointed it out so I could get started with the MDX.

Perhaps I should add that the user ##### is administrator for the entire server. The server administrator role should take precedence over database roles, right (not that it helped when I added one of those and included me)? The user is also a member of the SQLServer2005OLAPUser group. I also have full access to the underlying relational database. So I can delete or create elements or entire databases at will but not ask simple questions to them...

The other option - that the cube doesn't exist seems dispelled by being able to browse it and the dimensions etc. showing up in object explorers and in the left pane of the MDX Query interface.

Which leaves me at some permission problem again - some help would REALLY be appreciated.

|||Please provide more information as something strange is going on here - given what you have provided, you should not be having a permission error - but, the error message does not make sense as the Analysis Services Tutorial has no data mining component.|||

I don't have the queries I tested with anymore since I got it to work but the bottomline was that I didn't have any "ON ROW|COLUMNS" etc. part of the selection clause which obviously sent the engine looking for something that didn't exist. I.e. just had queries with variations on the form:

SELECT dim

FROM cube

Looked at what the browser sent with the profiler and changed to:

SELECT dim ON 0

FROM cube

and everything has been working well since then. Perhaps a bit strange errormessage but otherwise my mistake. Sorry for taking up your time with this one

|||

I am new to Analysis services. I migared on of the Sql 2000 cube to sql 2005 .I am getting the same message , when i use Pivot table to dipaly data from sql 2005 Cube.With sql 2000, it works great.Here is the eror message.

Error (Data mining): Either the user, Domain/User doen not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist. Error (Data mining): Either the user, DOMAIN\USER , does not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist.

When i ran Profiler , it is trying to run the following sql statement.

SELECT * FROM "SalesHistoryData "

I have granted all high level rights.Still not working.

Expecting fix from someone.

|||

hi, i recv the same while trying to query the cube from SSMS...

Error (Data mining): Either the user, domain\account, does not have permission to access the referenced mining model, MaxMinSalesDM, or the object does not exist.

no error building or deploying the cube..

can see the cube in the database folder as well

please help...

|||

sorry, my mistake...

it should be select from [Cube Name], not select * from [Cube Name]

|||

My issue solved.I just had to change the Data Source Provider to msolap.2 to msolap.3 in the Pivot table properties.

You may also have to try with just msolap(No vesion) in case the above change doesn't fix it.

Connection Error when trying to run MDX-queries

To learn MDX (on SQL Server 2005 dev edition) I decided to put up some sample cubes and run MDX-queries from SQL Server Management Studio. When processing the cube in BI Studio I get the following error:

"The datasource , 'Adventure Works DW', contains an ImpersonationMode that that is not supported for processing operations."

Fair enough, then I change the impersonationmode in the datasource to service account. It all processes/deploys well and I can browse the cube in BI Studio. Off to Management studio to run some mdx-queries. Here however I get the error:

"Error (Data mining): Either the user, ######, does not have permission to access the referenced mining model, Analysis Services Tutorial, or the object does not exist."

That is of course due to me using the current user credentials for the query. So I try to change the current connection in management studio but the helpbutton informs me that as of now only windowsauthentication can be used for analysis services. So the only connectionway I can use from here is the only one not supported when processing?! This must mean I've done some childishly simple newbiemistake and I would be very grateful if you pointed it out so I could get started with the MDX.

Perhaps I should add that the user ##### is administrator for the entire server. The server administrator role should take precedence over database roles, right (not that it helped when I added one of those and included me)? The user is also a member of the SQLServer2005OLAPUser group. I also have full access to the underlying relational database. So I can delete or create elements or entire databases at will but not ask simple questions to them...

The other option - that the cube doesn't exist seems dispelled by being able to browse it and the dimensions etc. showing up in object explorers and in the left pane of the MDX Query interface.

Which leaves me at some permission problem again - some help would REALLY be appreciated.

|||Please provide more information as something strange is going on here - given what you have provided, you should not be having a permission error - but, the error message does not make sense as the Analysis Services Tutorial has no data mining component.|||

I don't have the queries I tested with anymore since I got it to work but the bottomline was that I didn't have any "ON ROW|COLUMNS" etc. part of the selection clause which obviously sent the engine looking for something that didn't exist. I.e. just had queries with variations on the form:

SELECT dim

FROM cube

Looked at what the browser sent with the profiler and changed to:

SELECT dim ON 0

FROM cube

and everything has been working well since then. Perhaps a bit strange errormessage but otherwise my mistake. Sorry for taking up your time with this one

|||

I am new to Analysis services. I migared on of the Sql 2000 cube to sql 2005 .I am getting the same message , when i use Pivot table to dipaly data from sql 2005 Cube.With sql 2000, it works great.Here is the eror message.

Error (Data mining): Either the user, Domain/User doen not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist. Error (Data mining): Either the user, DOMAIN\USER , does not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist.

When i ran Profiler , it is trying to run the following sql statement.

SELECT * FROM "SalesHistoryData "

I have granted all high level rights.Still not working.

Expecting fix from someone.

|||

hi, i recv the same while trying to query the cube from SSMS...

Error (Data mining): Either the user, domain\account, does not have permission to access the referenced mining model, MaxMinSalesDM, or the object does not exist.

no error building or deploying the cube..

can see the cube in the database folder as well

please help...

|||

sorry, my mistake...

it should be select from [Cube Name], not select * from [Cube Name]

|||

My issue solved.I just had to change the Data Source Provider to msolap.2 to msolap.3 in the Pivot table properties.

You may also have to try with just msolap(No vesion) in case the above change doesn't fix it.

Connection Error when trying to run MDX-queries

To learn MDX (on SQL Server 2005 dev edition) I decided to put up some sample cubes and run MDX-queries from SQL Server Management Studio. When processing the cube in BI Studio I get the following error:

"The datasource , 'Adventure Works DW', contains an ImpersonationMode that that is not supported for processing operations."

Fair enough, then I change the impersonationmode in the datasource to service account. It all processes/deploys well and I can browse the cube in BI Studio. Off to Management studio to run some mdx-queries. Here however I get the error:

"Error (Data mining): Either the user, ######, does not have permission to access the referenced mining model, Analysis Services Tutorial, or the object does not exist."

That is of course due to me using the current user credentials for the query. So I try to change the current connection in management studio but the helpbutton informs me that as of now only windowsauthentication can be used for analysis services. So the only connectionway I can use from here is the only one not supported when processing?! This must mean I've done some childishly simple newbiemistake and I would be very grateful if you pointed it out so I could get started with the MDX.

Perhaps I should add that the user ##### is administrator for the entire server. The server administrator role should take precedence over database roles, right (not that it helped when I added one of those and included me)? The user is also a member of the SQLServer2005OLAPUser group. I also have full access to the underlying relational database. So I can delete or create elements or entire databases at will but not ask simple questions to them...

The other option - that the cube doesn't exist seems dispelled by being able to browse it and the dimensions etc. showing up in object explorers and in the left pane of the MDX Query interface.

Which leaves me at some permission problem again - some help would REALLY be appreciated.

|||Please provide more information as something strange is going on here - given what you have provided, you should not be having a permission error - but, the error message does not make sense as the Analysis Services Tutorial has no data mining component.|||

I don't have the queries I tested with anymore since I got it to work but the bottomline was that I didn't have any "ON ROW|COLUMNS" etc. part of the selection clause which obviously sent the engine looking for something that didn't exist. I.e. just had queries with variations on the form:

SELECT dim

FROM cube

Looked at what the browser sent with the profiler and changed to:

SELECT dim ON 0

FROM cube

and everything has been working well since then. Perhaps a bit strange errormessage but otherwise my mistake. Sorry for taking up your time with this one

|||

I am new to Analysis services. I migared on of the Sql 2000 cube to sql 2005 .I am getting the same message , when i use Pivot table to dipaly data from sql 2005 Cube.With sql 2000, it works great.Here is the eror message.

Error (Data mining): Either the user, Domain/User doen not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist. Error (Data mining): Either the user, DOMAIN\USER , does not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist.

When i ran Profiler , it is trying to run the following sql statement.

SELECT * FROM "SalesHistoryData "

I have granted all high level rights.Still not working.

Expecting fix from someone.

|||

hi, i recv the same while trying to query the cube from SSMS...

Error (Data mining): Either the user, domain\account, does not have permission to access the referenced mining model, MaxMinSalesDM, or the object does not exist.

no error building or deploying the cube..

can see the cube in the database folder as well

please help...

|||

sorry, my mistake...

it should be select from [Cube Name], not select * from [Cube Name]

|||

My issue solved.I just had to change the Data Source Provider to msolap.2 to msolap.3 in the Pivot table properties.

You may also have to try with just msolap(No vesion) in case the above change doesn't fix it.

Connection Error when trying to run MDX-queries

To learn MDX (on SQL Server 2005 dev edition) I decided to put up some sample cubes and run MDX-queries from SQL Server Management Studio. When processing the cube in BI Studio I get the following error:

"The datasource , 'Adventure Works DW', contains an ImpersonationMode that that is not supported for processing operations."

Fair enough, then I change the impersonationmode in the datasource to service account. It all processes/deploys well and I can browse the cube in BI Studio. Off to Management studio to run some mdx-queries. Here however I get the error:

"Error (Data mining): Either the user, ######, does not have permission to access the referenced mining model, Analysis Services Tutorial, or the object does not exist."

That is of course due to me using the current user credentials for the query. So I try to change the current connection in management studio but the helpbutton informs me that as of now only windowsauthentication can be used for analysis services. So the only connectionway I can use from here is the only one not supported when processing?! This must mean I've done some childishly simple newbiemistake and I would be very grateful if you pointed it out so I could get started with the MDX.

Perhaps I should add that the user ##### is administrator for the entire server. The server administrator role should take precedence over database roles, right (not that it helped when I added one of those and included me)? The user is also a member of the SQLServer2005OLAPUser group. I also have full access to the underlying relational database. So I can delete or create elements or entire databases at will but not ask simple questions to them...

The other option - that the cube doesn't exist seems dispelled by being able to browse it and the dimensions etc. showing up in object explorers and in the left pane of the MDX Query interface.

Which leaves me at some permission problem again - some help would REALLY be appreciated.

|||Please provide more information as something strange is going on here - given what you have provided, you should not be having a permission error - but, the error message does not make sense as the Analysis Services Tutorial has no data mining component.|||

I don't have the queries I tested with anymore since I got it to work but the bottomline was that I didn't have any "ON ROW|COLUMNS" etc. part of the selection clause which obviously sent the engine looking for something that didn't exist. I.e. just had queries with variations on the form:

SELECT dim

FROM cube

Looked at what the browser sent with the profiler and changed to:

SELECT dim ON 0

FROM cube

and everything has been working well since then. Perhaps a bit strange errormessage but otherwise my mistake. Sorry for taking up your time with this one

|||

I am new to Analysis services. I migared on of the Sql 2000 cube to sql 2005 .I am getting the same message , when i use Pivot table to dipaly data from sql 2005 Cube.With sql 2000, it works great.Here is the eror message.

Error (Data mining): Either the user, Domain/User doen not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist. Error (Data mining): Either the user, DOMAIN\USER , does not have permission to access the referenced mining model, SalesHistoryData , or the object does not exist.

When i ran Profiler , it is trying to run the following sql statement.

SELECT * FROM "SalesHistoryData "

I have granted all high level rights.Still not working.

Expecting fix from someone.

|||

hi, i recv the same while trying to query the cube from SSMS...

Error (Data mining): Either the user, domain\account, does not have permission to access the referenced mining model, MaxMinSalesDM, or the object does not exist.

no error building or deploying the cube..

can see the cube in the database folder as well

please help...

|||

sorry, my mistake...

it should be select from [Cube Name], not select * from [Cube Name]

|||

My issue solved.I just had to change the Data Source Provider to msolap.2 to msolap.3 in the Pivot table properties.

You may also have to try with just msolap(No vesion) in case the above change doesn't fix it.