• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

use a database schema from java using jdbc

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to execute a sql query from java using jdbc and its throwing me an db exception. here is the code -
----------------------------------------------------------------------------------------------
String query = "use primus \ngo\n";
query = query + "select o.name , text = convert(char(255) not null, text) " +
"from sysobjects o, syscomments s "+
"where o.type = 'P' and s.id = object_id(o.name) order by o.name";
PreparedStatement st = conn.prepareStatement(query);
ResultSet rs = st.executeQuery();
---------------------------------------------------------------------------------------------
and here is the exception -
SQL Exception:Incorrect syntax near 'go'.

But the same code is working when I am running it directly in the database.

Please help

Thanks
Suman
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suman,
That looks like two statements. Why not write it as one?

from primus.sysobjects o
 
reply
    Bookmark Topic Watch Topic
  • New Topic