Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.databases > #368

Re: Java Database connect

From "Yogi" <yogi@THRWHITE.remove-dii-this>
Subject Re: Java Database connect
Message-ID <a18b0397-b884-49c4-a949-587110fc684e@s9g2000prg.googlegroups.com> (permalink)
Newsgroups comp.lang.java.databases
References <3eb53747-8115-4db7-a579-82fc43ac3a22@k24g200
Date 2011-04-27 15:23 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.databases
On Nov 17, 8:17 pm, Yogi <yogeshkagra...@gmail.com> wrote:
> On Nov 17, 6:02 pm, Yogi <yogeshkagra...@gmail.com> wrote:
>
>
>
> > On Nov 17, 5:57 pm, Sabine Dinis Blochberger <no.s...@here.invalid>
> > wrote:
>
> > > Yogi wrote:
> > > > On Nov 17, 5:30 pm, Sabine Dinis Blochberger <no.s...@here.invalid>
> > > > wrote:
> > > > > Yogi wrote:
> > > > > > On Nov 17, 2:30 pm, Sabine Dinis Blochberger <no.s...@here.invalid>
> > > > > > wrote:
> > > > > > > Yogi wrote:
> > > > > > > > I am new to java and db connection pooling. I tried using Apache's
> > > > > > > > DBCP for connection pool for my web application.  Was trying to do
> > > > > > > > similar thing for a standalone server (not a web based).  I tried
> > > > > > > > using DBCP but i am getting strange results.  In my string variables,
> > > > > > > > i am getting "???" as output whereas for int variables i am getting
> > > > > > > > correct values when i m trying to read from database.
>
> > > > > > > Make sure you use the correct encoding when connecting to the databse,
> > > > > > > for example, UTF-8. Refer to the manual of the database and JDBC driver
> > > > > > > for specifics.
>
> > > > > This could be only a display problem then - on your other environment
> > > > > you don't have the correct locales installed.
>
> > > > I am using Eclipse to execute my program and getting "???" in
> > > > Eclipse's console.  One of my friend suggested to check for dependent
> > > > jars while using Apache's DBCP.  But what I am bothered about is, if
> > > > dependent jars are not available, it should not give me correct values
> > > > for integer placeholders as well.  Any comments?
>
> > > If you were missing libraries, you would get an Exception telling you
> > > so.
>
> > > Ok, from the Javadocs [0]:
>
> > > "public void print(String s)
> > > Prints a string. If the argument is null then the string "null" is
> > > printed. Otherwise, the string's characters are converted into bytes
> > > according to the platform's default character encoding, and these bytes
> > > are written in exactly the manner of the write(int) method.
>
> > > Parameters:
> > > s - The String to be printed"
>
> > > Instead of using System.out.println, use a logging facility?
> > > Or set your environments default character encoding to UTF-8 [1]?
>
> > > [0]
> > > <http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html#print(...)>
>
> > > [1] <http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg07331.html>
>
> > Ok. This might be one of the issues.  I will check your solutions and
> > will update you. Thanks a ton for your inputs. :)
>
> Still no progress.  Here is how I modified my Test class:
> --------------
>    public static void main(String[] args){
>            Test t1 = new Test();
>
>            List <DInfo> dList = EngineDBManager.getDInfo();
>            BufferedWriter out=null;
>            try {
>                out = new BufferedWriter(new FileWriter("c:\\test.out"));
>            }catch(Exception e){
>                   System.out.println("Not able to open file for writing");
>            }
>
>            OutputStreamWriter out1 = new OutputStreamWriter(new
> ByteArrayOutputStream());
>            System.out.println("Printing Encoding type here:" +
> out1.getEncoding());
>
>            DInfo d = null;
>            if (dList == null){
>               System.out.println("DInfo is null");
>            }else{
>                    for (int i=0;i < dList.size(); i++){
>                              d = (DInfo) dList.get(i);
>                              System.out.println("Id=" + d.getDID() + " Desc=" + d.getDDesc
> ());
>                              try{
>                                 out.write("\nId="+ d.getDID() + " Desc=" + d.getDDesc());
>                              }catch(Exception e){
>                                 System.out.println("error writing to file for=" +
> dist.getDistrictID());
>                              }
>                    }
>            }
>            try{
>               out.close();
>            }catch(Exception e){
>
>            }
>
>    }
> --------------------
> I am getting "???" description.  I changed encoding of Eclipse to UTF8.

I tried all possible ways but still no success.  Any setting required
in eclipse or at db level?  Any suggestions?

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.databases | Previous | Next | Find similar


Thread

Re: Java Database connect "Yogi" <yogi@THRWHITE.remove-dii-this> - 2011-04-27 15:23 +0000

csiph-web