 |
|
 |
|
Next: Storing "deleted" data
|
| Author |
Message |
External

Since: Oct 30, 2005 Posts: 2
|
(Msg. 1) Posted: Sun Oct 30, 2005 6:55 pm
Post subject: Java and Microsoft SQL Archived from groups: comp>lang>java>databases (more info?)
|
|
|
Hi !
I am experiencing some problems with MSSQL (ver 8.0).
While I can execute sub-select statement directly on a MSSQL server,
I cannot do the same thing in JDBC.
Like the following statement( JDBC throws exception about mismatched
type)
select idcolumn,a,b,c FROM mytable WHERE idcolumn = (SELECT max
(idcolumn) FROM mytable)
I could get the result other way too (like top 1 and descend sort
etc..), but this would be the fastest way and I want to use it.
I am connecting to database server without any settings, just IP,
username and password.
On mysql, I had a several options I could specify in a connect string,
so the server acts different.
Is there any setting I can specify which can help me ? Where can I
read all parameters I can specify when connecting via JDBC to Microsoft
SQL ?
Thx. >> Stay informed about: Java and Microsoft SQL |
|
| Back to top |
|
 |  |
External

Since: May 07, 2005 Posts: 42
|
(Msg. 2) Posted: Sun Oct 30, 2005 6:55 pm
Post subject: Re: Java and Microsoft SQL [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
wrote...
> I am experiencing some problems with MSSQL (ver 8.0).
Actually, I think the problem you encounter cannot be referred to as a
problem with MSSQL, other than that the use of the equals operator on a
nonscalar value AFAIK isn't a part of the ANSI-standard for SQL...
> While I can execute sub-select statement directly
> on a MSSQL server, I cannot do the same thing in JDBC.
>
> Like the following statement( JDBC throws exception
> about mismatched type)
>
> select idcolumn,a,b,c FROM mytable WHERE idcolumn =
> (SELECT max (idcolumn) FROM mytable)
Have you tried this instead: (?)
select idcolumn,a,b,c
FROM mytable
WHERE idcolumn IN
(SELECT max (idcolumn) FROM mytable)
// Bjorn A >> Stay informed about: Java and Microsoft SQL |
|
| Back to top |
|
 |  |
External

Since: Oct 01, 2003 Posts: 119
|
(Msg. 3) Posted: Mon Oct 31, 2005 7:55 am
Post subject: Re: Java and Microsoft SQL [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Bjorn Abelli wrote:
> wrote...
>
>> I am experiencing some problems with MSSQL (ver 8.0).
>
> Actually, I think the problem you encounter cannot be referred to as a
> problem with MSSQL, other than that the use of the equals operator on
> a nonscalar value AFAIK isn't a part of the ANSI-standard for SQL...
>
>> While I can execute sub-select statement directly
>> on a MSSQL server, I cannot do the same thing in JDBC.
>>
>> Like the following statement( JDBC throws exception
>> about mismatched type)
>>
>> select idcolumn,a,b,c FROM mytable WHERE idcolumn =
>> (SELECT max (idcolumn) FROM mytable)
>
> Have you tried this instead: (?)
>
> select idcolumn,a,b,c
> FROM mytable
> WHERE idcolumn IN
> (SELECT max (idcolumn) FROM mytable)
I'd prefer a join here:
select idcolumn,a,b,c
FROM mytable
,(SELECT max(idcolumn) as mi FROM mytable) mt
WHERE idcolumn = mt.mi
Kind regards
robert >> Stay informed about: Java and Microsoft SQL |
|
| Back to top |
|
 |  |
External

Since: Oct 31, 2005 Posts: 1
|
(Msg. 4) Posted: Mon Oct 31, 2005 7:55 am
Post subject: Re: Java and Microsoft SQL [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
> Have you tried this instead: (?)
>
> select idcolumn,a,b,c
> FROM mytable
> WHERE idcolumn IN
> (SELECT max (idcolumn) FROM mytable)
Yes, but doesn't work either. Altough *BOTH* works in SQL Query Analyzer
client,(or any other).
Some time ago, someone told me, that there are some options you can
specify in connect string (like MSSQL7=true or something). >> Stay informed about: Java and Microsoft SQL |
|
| Back to top |
|
 |  |
External

Since: Oct 01, 2003 Posts: 119
|
(Msg. 5) Posted: Mon Oct 31, 2005 8:55 am
Post subject: Re: Java and Microsoft SQL [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
bunka.munka.DeleteThis@email.si wrote:
>> Have you tried this instead: (?)
>>
>> select idcolumn,a,b,c
>> FROM mytable
>> WHERE idcolumn IN
>> (SELECT max (idcolumn) FROM mytable)
>
> Yes, but doesn't work either. Altough *BOTH* works in SQL Query
> Analyzer client,(or any other).
> Some time ago, someone told me, that there are some options you can
> specify in connect string (like MSSQL7=true or something).
Can you post the exact error?
robert >> Stay informed about: Java and Microsoft SQL |
|
| Back to top |
|
 |  |
External

Since: Oct 30, 2005 Posts: 2
|
(Msg. 6) Posted: Mon Oct 31, 2005 4:55 pm
Post subject: Re: Java and Microsoft SQL [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article , bob.news.TakeThisOut@gmx.net says...
> bunka.munka.TakeThisOut@email.si wrote:
> >> Have you tried this instead: (?)
> >>
> >> select idcolumn,a,b,c
> >> FROM mytable
> >> WHERE idcolumn IN
> >> (SELECT max (idcolumn) FROM mytable)
> >
> > Yes, but doesn't work either. Altough *BOTH* works in SQL Query
> > Analyzer client,(or any other).
> > Some time ago, someone told me, that there are some options you can
> > specify in connect string (like MSSQL7=true or something).
>
> Can you post the exact error?
>
> robert
>
>
select idcolumn,a,b,c FROM mytable WHERE idcolumn = (SELECT max
(idcolumn) FROM mytable)
is now working. actually it has worked before too.
The mistake I made was actually in the next line ( if rst.next() ....),
where I added wrong column seqence number when retrieving columns.
rst.get...
Usually I catch every statement in own try...catch, but this program is
not so important, so I put all together and therefore I didn't reallize
which statement actually throws exception.
Thanks anyway for support... >> Stay informed about: Java and Microsoft SQL |
|
| Back to top |
|
 |  |
| Related Topics: | Can Java executes Microsoft Access Macro? - Is there any way to run a Macro of Access database from Java? How to do it if so? I searched the internet, I have not found an answer yet. It seems there is no way. true or false? We have a lot of statistic charts generated by Macros of either Acces...
java.sql.SQLException [Microsoft][ODBC Driver Manag - OK, I've see a lot of stuff out there on this error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. The only definitive solution I can find is going to Control Panel-->Administrativ...
How to make JDBC/ODBC work with Microsoft Access - Hi, ALl: I am green on java and JDBC/ODBC. Would someone help me on how to set up the JDBC/ODBC thing with Microsoft ACCESS? I know the code in java from book though. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection dbConnection =..
java - Hello Im working with jdbc on a MSSQL Database. In my java client im executing a stored procedure called myProc on the database. Im doing this with the following code: ...... Statement stmt = con.createStatement(); String sql1 ="execute myProc&quo...
java or c# please help - I am starting a new application, it needs to use db such as access or msde. I know I can do this easily in c# or Java but my question is can I distribute a package as easy if it is created with java and say derby db as I can with windows based. It.... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|