GetColumns(String x,String y,String z,String w) method in  DatabaseMetaData

hi!
i want information about tables n their columns for perticular database.
i m using getcolums(String catlog,String schemapattern,String tablenamepattern,String columnnamepattern) method in DatabaseMetaData.I m using sql server 2000 as my db n i want all columns from all the tables.
what should be the last 2 string parameters in the above method.
i have tried the following.
DatabaseMetaData dbmd = dbcon.getMetaData();//dbcon is connection object
ResultSet rs = dbmd.getColumns("students","dbo","*","*");
while(rs.next())
this code does not enter the while loop what cud b the problem??

what should be the last 2 string parameters in the
above method.
dbmd.getColumns("students","dbo","*","*");The wildcard character in SQL is % not *
(Why are some many people using the * as the wildcard?)
dbmd.getColumns("students","dbo","%","%");
Should return all columns for all tables.
Thomas

Similar Messages

  • Need help in the String Format method

    really need help in string.Format method. I would like to show the s in two digit numbers.
    for example:
    if s is below 10 then display *0s*
    the expecting result is 01,02,03.. 09,10,11....
    I tried this method, somehow i got the errors msg. pls advise. thx.
    public void setDisplay(String s) {
    String tmpSS=String.format("%02d",s);
    this.ss.setText(tmpSS);
    Edited by: bluesailormoon on May 19, 2008 10:30 AM

    Apparently, you expect the string to consist of one or two digits. If that's true, you could do this:String tmpSS = (s.length() == 1) ? ("0" + s) : s; or this: String tmpSS = String.format("%02d", Integer.parseInt(s));

  • Question about the java doc of String.intern() method

    hi all, my native language is not english, and i have a problem when reading the java doc of String.intern() method. the following text is extract from the documentation:
    When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.
    i just don't know the "a reference to this String object is returned" part, does the "the reference to this String" means the string that the java keyword "this" represents or the string newly add to the string pool?
    eg,
    String s=new String("abc");  //create a string
    s.intern();  //add s to the string pool, and return what? s itself or the string just added to string pool?greate thanks!

    Except for primitives (byte, char, short, int, long, float, double, boolean), every value that you store in a variable, pass as a method parameter, return from a method, etc., is always a reference, never an object.
    String s  = "abc"; // s hold a reference to a String object containing chars "abc"
    foo(s); // we copy the reference in variable s and pass it to the foo() method.
    String foo(String s) {
      return s + "zzz"; // create a new String and return a reference that points to it.
    s.intern(); //add s to the string pool, and return what? s itself or the string just added to string pool?intern returns a reference to the String object that's held in the pool. It's not clear whether the String object is copied, or if it's just a reference to the original String object. It's also not relevant.

  • Strange behavior of std::string find method in SS12

    Hi
    I faced with strange behavior of std::string.find method while compiling with Sunstudio12.
    Compiler: CC: Sun C++ 5.9 SunOS_sparc Patch 124863-14 2009/06/23
    Platform: SunOS xxxxx 5.10 Generic_141414-07 sun4u sparc SUNW,Sun-Fire-V250
    Sometimes find method does not work, especially when content of string is larger than several Kb and it is needed to find pattern from some non-zero position in the string
    For example, I have some demonstration program which tries to parse PDF file.
    It loads PDF file completely to a string and then iterately searches all ocurrences of "obj" and "endobj".
    If I compile it with GCC from Solaris - it works
    If I compile it with Sunstudio12 and standard STL - does not work
    If I compile it with Sunstudio12 and stlport - it works.
    On win32 it always works fine (by VStudio or CodeBlocks)
    Is there any limitation of standard string find method in Sunstudio12 STL ?
    See below the code of tool.
    Compilation: CC -o teststr teststr.cpp
    You can use any PDF files larger than 2kb as input to reproduce the problem.
    In this case std::string failes to find "endobj" from some position in the string,
    while this pattern is located there for sure.
    Example of output:
    CC -o teststr teststr.cpp
    teststr in.pdf Processing in.pdf
    Found object:1
    Broken PDF, endobj is not found from position1155
    #include <string>
    #include <iostream>
    #include <fstream>
    using namespace std;
    bool parsePDF (string &content, size_t &position)
        position = content.find("obj",position);
        if( position == string::npos ) {
            cout<<"End of file"<<endl;
            return false;
        position += strlen("obj");
        size_t cur_pos = position;
        position = content.find("endobj",cur_pos);
        if( position == string::npos ){
            cerr<<"Broken PDF, endobj is not found from position"<<cur_pos<<endl;;
            return false;
        position += strlen("endobj");
        return true;
    int main(int argc, char ** argv)
        if( argc < 2 ){
            cout<<"Usage:"<<argv[0]<<" [pdf files]\n";
            return -3;
        else {
            for(int i = 1;i<argc;i++) {
                ifstream pdfFile;
                pdfFile.open(argv,ios::binary);
    if( pdfFile.fail()){
    cerr<<"Error opening file:"<<argv[i]<<endl;
    continue;
    pdfFile.seekg(0,ios::end);
    int length = pdfFile.tellg();
    pdfFile.seekg(0,ios::beg);
    char *buffer = new char [length];
    if( !buffer ){
    cerr<<"Cannot allocate\n";
    continue;
    pdfFile.read(buffer,length);
    pdfFile.close();
    string content;
    content.insert(0,buffer,length);
    delete buffer;
    // the lets parse the file and find all endobj in the buffer
    cout<<"Processing "<<argv[i]<<endl;
    size_t start = 0;
    int count = 0;
    while( parsePDF(content,start) ){
    cout<<"Found object:"<<++count<<"\n";
    return 0;

    Well, there is definitely some sort of problem here, maybe in string::find, but possibly elsewhere in the library.
    Please file a bug report at [http://bugs.sun.com] and we'll have a look at it.

  • Problem using java String.split() method

    Hi all, I have a problem regarding the usage of java regular expressions. I want to use the String.split() method to tokenize a string of text. Now the problem is that the delimiter which is to be used is determined only at runtime and it can itself be a string, and may contain the characters like *, ?, + etc. which are treated as regular expression constructs.
    Is there a way to tell the regular expression that it should not treat certain characters as quantifiers but the whole string should be treated as a delimiter? I know one solution is to use the StringTokenizer class but it's a legacy class & its use is not recommended in Javadocs. So, does there exist a way to get the above functionality using regular expressions.
    Please do respond if anyone has any idea. Thanx
    Hamid

    public class StringSplit {
    public static void main(String args[]) throws Exception{
    new StringSplit().doit();
    public void doit() {
    String s3 = "Dear <TitleNo> ABC Letter Details";
    String[] temp = s3.split("<>");
    dump(temp);
    public void dump(String []s) {
    System.out.println("------------");
    for (int i = 0 ; i < s.length ; i++) {
    System.out.println(s);
    System.out.println("------------");
    Want to extract only string between <>
    for example to extract <TitleNo> only.
    any suggestions please ?

  • How to sort a list of strings, without methods and stuff just simple code?

    Hi
    How to sort a list of strings, without methods and stuff just simple code?
    Thanks in adavance!!

    Without methods? How are you going to all the sort code? What is the point of code?
    Collections.sort(List) will sort strings or anything that implements the Comparable interface, or you can use the sort method that takes a Comparator implemenation.
    If you want "just code", you could either get the Collections class souce and follow it to the code. But otherwise, there isn't one set of code. There are various sorting algorithms with advantages and disadvantages. Maybe you'd be better off searching for sorting algorithms and if you understand them, it should be simple to write Java implementations of them.

  • Find(String pkey) method returns multiple object of the same row

    I'm not quite sure what i've done or havent done, but I've implemented updating a row using the em.persist(Object) method.....works great, but after i did that a few times the find(String pkey) method returns multiple copies of 1 row in the db
    here are two rows in the db
    personid(PK) firstName lastName
    1234 joe jones
    2345 rachel jones
    when i execute any query looking for people with the last name jones, ie
    select object(p) from Person p where p.lastName='jones'
    it returns multiple objects of each row ie
    1234 joe jones
    1234 joe jones
    1234 joe jones
    1234 joe jones
    2345 rachel jones
    2345 rachel jones
    2345 rachel jones
    2345 rachel jones
    There is only one row for both rachel and joe in the db, but why is the entity manager returning multiple objects of each, and how do i prevent that without using DISTINCT?
    Thanks for the help in advance

    Sorry, i forgot to mention i'm using ejb 3 and jboss

  • Problems with String.getBytes() method

    Consider this code
        for(int k=0 ; k<256 ; k++)
           char[] cc = {(char)k};
           String xxx = new String(cc);
           byte b1 = (byte)xxx.charAt(0);
           byte[] bb = xxx.getBytes();
           byte b2 = bb[0];
           boolean diff = (b1!=b2);
           if (diff)
           System.out.println(k+" - "+b1+" - "+b2);
         }for k from 128 to 159 b1 and b2 are different and in particular b2 (that is the result of getString() method) is every time equals to 63.
    Does someone know if it is a bug or what else.

    char variables store 16 bit UNICODE characters. If you cast char to byte you're just taking the low order 8-bits of a unicode character.
    On the other hand getBytes attempts to convert a character into a byte, or sequence of bytes using the default character encoding of the machine, which won't generally corespond. National character encodings meen that non-ASCII characters, including national stuff like pound sign, may well map from UNICODE characters above 255 into a single byte.
    The character encoding which does corespond to the bottom 8 bits of UNICODE is ISO-8859-1. If you try it with that your discrepancies will disappear.

  • String replaceall method

    public static String removeSpecialCharacters4JavaScript(String text)
              String result = null;
              if (text != null)
                  Hashtable forbidenEntities = PortalHelper.getTocForbidenEntities();
                   Enumeration keys = forbidenEntities.keys();
                   String key = null;
                   String value = null;
                   while (keys.hasMoreElements()) {
                        key = (String)keys.nextElement();
                        value = (String)forbidenEntities.get(key);
                        result = result.replaceAll("&"+key+";", value);
                   result = text.replaceAll("'","&#39;");
                   result = result.replaceAll("\"","&#34;");
              return result;
         i am getting problem at the replaceall method. plz suggest me here.
    thanks.

    Instead of iterating through the table and doing a replaceAll() for each entry, you should do one replaceAll(), looking up the replacement text in the table for each "hit". Elliott Hughes' Rewriter makes dynamic replacements like this easy to do.  private static Rewriter rewriter = new Rewriter("&(\\w+);|['\"]")
        public String replacement()
          if (group(1) != null)
            return (String)PortalHelper.getTocForbidenEntities().get(group(1));
          else if ("\"".equals(m.group(0))
            return "& quot;"; // remove the space
          else if ("'".equals(m.group(0))
            return "& apos;"; // remove the space
      public static String removeSpecialCharacters4JavaScript(String text)
        return rewriter.rewrite(text);
      }Just to be safe, in Rewriter.java replace the line            matcher.appendReplacement(result, replacement());with            matcher.appendReplacement(result, "");
                result.append(replacement());Otherwise you'll have problems whenever a dollar sign or backslash appears in the generated replacement text.

  • String parsing method

    Hi,
    Lets suppose I have the following string inputs:
    12345600
    43121000
    12093230
    12340000
    I need to write a methode that the input convert to the following output:
    12.34.56
    43.12.10
    12.09.32.30
    12.34
    So if you have two (four) succesive zeros at the end, you have to eliminate them.

    hi,
    use following code, it can handle inner-double-zeros too
    "123004500000" => "12.30.04.50"
    * Convert a long-value to a pointed string
    * "123450000" => "12.34.50"
    * "12300450000" => "12.30.04.50"
    * @author Oliver SCORP
    public final static String PointedString(long parLong) {
       try{
          String s = String.valueOf(parLong);
          if (s == null)
             return null;
          int idx = 0, idx2 = 0, idxt = 0, mod = 0;
          boolean zero = false, zero2 = false, zerozero = false;
          char[] ca = s.toCharArray();
          char[] ca2 = new char[ca.length * 2];
          char[] ca_temp = new char[ca.length * 2];
          char[] pat = new char[2];
          for (idx = 0; idx < ca.length; idx++){
             mod = idx % 2;
             if (mod == 0){
                pat[0] = ca[idx];
                if (ca[idx] == '0')
                   zero = true;
                } else {
                   pat[1] = ca[idx];
                   if (ca[idx] == '0')
                      zero2 = true;
                   if ((zero == true)&&(zero2 == true))
                      zerozero = true;
                   else
                      zerozero = false;
                   zero = false;
                   zero2 = false;
                   ca_temp[idxt] = '.';
                   ca_temp[idxt + 1] = pat[0];
                   ca_temp[idxt + 2] = pat[1];
                   idxt += 3;
                   if (!zerozero){
                      System.arraycopy(ca_temp, 0, ca2, idx2, idxt);
                      ca_temp = new char[ca.length * 2];
                      idx2 += idxt;
                      idxt = 0;
                   zerozero = false;
           char[] ca3 = new char[idx2 - 1];
           System.arraycopy(ca2, 1, ca3, 0, idx2 - 1);
           s = String.valueOf(ca3);
           return s;
           }catch(Exception e){
              System.err.println(e.toString());
              return null;
    }cu
    Oliver SCORP

  • From string to method

    Hi all,
    i have a property file.
    i need to read from the file some string and activate a method with the same name.
    i know how to read the file.
    my question is how can i transfer from the string to actual method.
    Gabi

    How much of this are you doing? If it's a lot, then you may be reinventing the Spring .

  • Library of string manip methods

    Hi,
    I have written a library of methods for special String manipulations (such as padding, and packing) and I would like to make those methods easily accessible. In Java, what is the preferred way for me to do this? Should I create a subclass of String and and add my methods? Should I create a class with static methods and just call the methods that way?
    What I would really like to be able to do is create an interface that lets me call the methods without "object." notatation in classes that implement it, but I haven't been able to get that to work.
    Any suggesetions?
    -Benjamin

    What I would really like to be able to do is create an
    interface that lets me call the methods without
    "object." notatation in classes that implement it, but
    I haven't been able to get that to work.
    Any suggesetions?Yeah: wait until Tiger (j2sdk1.5) comes out. It's going to have a "static import" feature that does exactly what you describe. Until then, you're stuck with "ClassName.staticMethodName()".

  • String equal method Vs Object equal method.

    hello, Can anybody explain me difference between equal method in String class and equal method in Object class. We have equal method in object classes. and object class is the super class of all classes, so why we need equal method in String class.

    RGEO wrote:
    hello, Can anybody explain me difference between equal method in String class and equal method in Object class. We have equal method in object classes. and object class is the super class of all classes, so why we need equal method in String class.Because "equal" means different things for different objects. For a String, "equal" would mean that both Strings being compared have the exact same characters, in the same sequence. For an Integer, "equals" would mean that both objects have the same integer value.

  • Runtime.getRuntime().exec(java method); - Passing strings between methods

    Hi all,
    I am using Runtime.getRuntime().exec(java xxxxxx); to run a java program from within a java program, i also need to pass a string to the new program. Does anyone know how to do this?
    Matt

    how would i retrive those strings in myApp as i want
    to put the values from them in a JLabelYou have a main method like this, right?
    public static void main(String[] args) { ... }
    args contains the array of strings passed to the app from the command line.

  • XML Strings as method parameters with HTTP + proxy.

    Hi,
    We are stuck with the following problem...
    We have a client making a remote method call to an SessionBean, and one parameter of this method is a String, which has some well formed XML structure in it.
    When we call this method with RMI-IIOP over TCP, there is no problem. However, when we call the same method from long distance (like another building) using RMI-IIOP over HTTP (we have used HTTP Tunnelling facility of IBM WebSphere), some strange things happen.
    When we print the incoming XML String in the first case, all is well. However, in the second case the incoming string is just full RUBBISH characters (some binary stuff I guess).
    Configuration is such,
    App Server = IBM WebSphere 4.02
    App Server OS = Linux, Red Hat
    Client = Standalone Java Application
    HTTP Proxy = Squid
    If anyone knows why such a thing can happen, please help. Even a trail would be helpful.
    Thanks in advance...

    make sure you got the same encoding on both ends....

Maybe you are looking for