SQLServer 2005, jTDS and Netbeans

The thing I hate about SQLServer is that it gives me too much headache whenever I use it with Java. Since I already had share of of those from my last company, I already had some precautions.

  • Use jtds driver
  • Enable TCP/IP on default port 1433
  • For SQLServer 2000 be sure to atleast upgrade to SP4
  • And many others

Last night I wanted to test the CRUD feature of netbeans 5.5. I needed to generate Entity Classes from the database using one of the wizards. However, although I was able to connect to the database it didn't list the list of tables. I tried to check my JDBC url. I had to set this through the connetion property at the runtime view BTW.

 

jdbc:jtds:sqlserver://127.0.0.1:1433/ - OK
net.sourceforge.jtds.jdbc.Driver - OK


 
It took me until today to figure out and remember that my friend Sam set my username as an alias of dbo. What is dbo BTW? Like I care...

Anyway, in the connection properties my schema was set to wpinventorydb which was the name of my database. After a few trial and error I noticed that when I try to create a table through the runtime view (which failed BTW) the error message would say something like:

Unable to execute command:

create table "wpinventorydb."tablename"
{

    "id" TINYINT 
}

 

Hmmm... "wpinventorydb."tablename".... That rings a bell. I remember when I created a database through the SQL Server Management Studio(I'm using SQLServer  2005) my tables were saved with a name prefixed by dbo. So I just changed the schema from the connection properties from wpinventorydb to dbo then I became happy. Big Smile I'm not sure of the reason why, but it did the job.


 


 

Published Wednesday, April 18, 2007 1:37 AM by lamia
Filed under: , ,

Comments

# re: SQLServer 2005, jTDS and Netbeans

Wednesday, April 18, 2007 6:04 AM by bonskijr

hi lamia,

dbo - stands for database owner, if you have administrative rights on the db server, if you're not and you didn't explicitly tell Sql Server the owner will be your login. ex: lamia.yourTable, that's why upon creation of tables you should be explicit with the object owner.

hth

# re: SQLServer 2005, jTDS and Netbeans

Wednesday, April 18, 2007 11:11 PM by lamia

Hi! Thanks for the info! It would sure help a lot next time! :)

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: