Thursday, March 22, 2012

yahoooooooooooooooooooo dah dapatttt!!!! alhamdulillah!!!!!

The problem that bothered me for weeks now is over, alhamdulillah!!

what's going on actually?
I'm trying to insert data into the database using web service. The problem that makes me really frustrated is that the data that I have inserted using the web service didn't appear when I viewed the table in the database.

The solution :

The first thing to do is to create a new user for Microsoft SQL Server 2005. (When I browse the forums, it says that it only works when we chose Mix Mode when installing MS SQL Server (enabling both Windows and Sql server authentication)). Go to Databases--Profile1 (or your database)--Security--Users. Right click on User and choose New user. Enter new user name and login name. I put the same name which is my name. For Schema, I choose dbo. Make sure that the schema is consistent with the one that you choose when creating table in Netbeans, otherwise, the data you insert into the web service won't enter into the database. The rest you may see it in the following screen shot :



Later, go to the table that you're going to access, Databases--Profile1--Table,--db_owner.login (my table) and right click, go to Properties. On your left pane, click Permission. Under The User of Roles, click add to select the user that you have created previously. And later you may grant permission to the user.



In Netbeans, when you look under the Databases, make sure the table is under the right schema (in my case, login table is under dbo schema).



Finally, check the connection string in the java code,

("jdbc:sqlserver://localhost:1433;name:login;catalog=Profile1;schema=dbo;username=****;password=****")

'1433' is the port I use,'login' is the table name, 'Profile1' is the database name,'dbo' is the schema I chosed, ' username' and 'password' is the username and password that we have created previously. In the following screenshot, replace 'sa' with the username that has been created.


Finally we can deploy the project and test the web service, and InsyaAllah the data inserted will enter into the database....

phewww......
I am very tired today for resolving the problem all day long....
gonna have a good sleep....

No comments:

Post a Comment