Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The multi-part identifier "alias.field" could not be bound.

271 views
Skip to first unread message

kalakhr

unread,
Mar 10, 2010, 8:02:01 AM3/10/10
to
I am using sqljdbc_2.0.1803.100 version of the driver with SQLServer 2005.

create table table1(id int, name varchar(100));
create table table2(id int, name varchar(100));

insert into table1 (id, name) values(1,'A');
insert into table2 (id, name) values(1,'A');

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con =
DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=testdb",
"sa", "password");
PreparedStatement st = con.prepareStatement("select a.* from
table1 a left outer join table2 b on (a.id = b.id) where a.id = ?");
ParameterMetaData pmd = st.getParameterMetaData();


com.microsoft.sqlserver.jdbc.SQLServerException:
com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part identifier
"a.id" could not be bound.
at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at
com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.<init>(SQLServerParameterMetaData.java:426)
at
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getParameterMetaData(SQLServerPreparedStatement.java:1510)

joe.we...@gmail.com

unread,
Mar 10, 2010, 1:31:10 PM3/10/10
to

FWIW, I have duplicated the bug using MS's latest driver, version
2.0.1803.100,
and I also tried executing the statement before getting the parameter
metadata
and there was no change in the exception. Furthermore, I verified that
a
competing commercial JDBC driver for MS SQLServer did not have this
problem.
HTH,
Joe Weinstein at Oracle

Bala Mugun

unread,
Mar 10, 2010, 1:57:31 PM3/10/10
to
Hello, this is a known shortcoming of the driver. It does not support
joins for parameter metadata. You could workaround this by first
creating this as a stored procedure first then getting the parameter
metadata.

On Mar 10, 6:02 am, kalakhr <kala...@discussions.microsoft.com> wrote:
> I am using sqljdbc_2.0.1803.100 version of the driver with SQLServer 2005.
>
> create table table1(id int, name varchar(100));
> create table table2(id int, name varchar(100));
>
> insert into table1 (id, name) values(1,'A');
> insert into table2 (id, name) values(1,'A');
>
>             Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
>             Connection con =
> DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=testdb­",
> "sa", "password");
>             PreparedStatement st = con.prepareStatement("select a.* from
> table1 a left outer join table2 b on (a.id = b.id) where a.id = ?");
>             ParameterMetaData pmd = st.getParameterMetaData();
>
> com.microsoft.sqlserver.jdbc.SQLServerException:
> com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part identifier
> "a.id" could not be bound.
>         at

0 new messages