![]() |
|
Spaces home Object Oriented Programm...PhotosProfileFriendsMore ![]() | ![]() |
Object Oriented Programming in styleJune 28 Re: java code to evaluate a arithmetic expression....The code better implemented: - Please review and suggest a better implementation. Any comments are welcome. Download the code at: - http://myjavaserver.com/~pradyut/files/Calci.java The code: - --------------------------------------------------------------------------------------------------------------------------------------------------------------------- public class Calci { public static void main(String[] args) { String a = "4-(6-1)+3*9/2(8(6-1))(7-43)4-(6-1)+3.67*9/2(8(6.77+1))(7-4.3)"; //1*3+2*7-1-1 //(2+1)-(4-2)3/(-5) //3*(1-2) //4-(6-1)+3*9/2(8(6-1))(7-43) //14-(4/(6-9)) String[] b = null; String c = null; Calci obj = new Calci(); System.out.println(obj.parse(a)); } double func(String a) { double d = 0; return d; } String mult(String a, String b) { double c = func1(a) * func1(b); return (Double.toString(c)); } String minus(String a, String b) { double c = func1(a) - func1(b); System.out.println(c); return (Double.toString(c)); } String add(String a, String b) { double c = func1(a) + func1(b); return (Double.toString(c)); } String divide(String a, String b) { double c = func1(a) / func1(b); return (Double.toString(c)); } double func1(String a) { double d =0; try { d = Double.parseDouble(a); } catch (NumberFormatException n1) { System.out.println(n1); } return d; } String parse(String a) { String b = null; String c = null, d= null, e=null; int z=0, f=0; if(a.contains("(")) { //System.out.println(b[0]); z = a.lastIndexOf("("); f = a.indexOf(")", z)+1; c = a.substring(z, f); b =a.substring(0, z); d = a.substring(f, a.length()); //processing b if(b.length() >=1) { e = String.valueOf(b.charAt(b.length()-1)); if(e.equals("+") || e.equals("-") || e.equals("*") || e.equals("/") || e.equals("(")) { }else { b = b+ "*"; } //System.out.println("b is: " + b); } //processing d if(d.length() >1) { e = String.valueOf(d.charAt(0)); if(e.equals("+") || e.equals("-") || e.equals("*") || e.equals("/") || e.equals(")")) { }else { d = "*" + d; } //System.out.println("d is: "+d); } c = check(brackets(c)); //System.out.println("c is: "+c); //c = "5"; a = b + c + d; if(a.contains("*-")) { //System.out.println("inside a is: "+a); z = a.indexOf("*-"); b = a.substring(0, z); //System.out.println("inside b is: "+b); a = a.substring(z, a.length()); b = repl(b); //System.out.println("inside a is: "+a); a= a.replace("*-", "*"); a = b+a; } else if (a.contains("--")) { a= a.replace("--", "+"); } else if (a.contains("+-")) { a= a.replace("+-", "-"); } else if (a.contains("/-")) { z = a.indexOf("/-"); b = a.substring(0, z); //System.out.println("inside b is: "+b); a = a.substring(z, a.length()); /*if( b.lastIndexOf('+') > b.lastIndexOf('-')) b=b.replace(b.charAt(b.lastIndexOf('+')), '-'); else b=b.replace(b.charAt(b.lastIndexOf('-')), '+'); */ b=repl(b); //System.out.println("inside a is: "+a); a= a.replace("/-", "/"); a = b+a; } System.out.println("a is: "+a); return parse(a); //System.out.println(a.substring(a.lastIndexOf("(")+1, a.indexOf(")", z))); } else return check(a); } String repl(String b) { int j,k,l; String h; if(b.length() >1) { if(b.contains("+") || b.contains("-")) { j = b.lastIndexOf('+'); k = b.lastIndexOf('-'); l = b.lastIndexOf(')'); if (l<j || l<k) { if( b.lastIndexOf('+') > b.lastIndexOf('-')) { System.out.println("inside"); b=b.replace(b.charAt(b.lastIndexOf('+')), '-'); return b; } else { //System.out.println("test B"); System.out.println("inside 1"); b=b.replace(b.charAt(b.lastIndexOf('-')), '+'); return b; } } else { System.out.println("inside 2"); h = b.substring(0, b.lastIndexOf('(')); System.out.println("h is: "+h); b = b.substring(b.lastIndexOf('('), b.length()); System.out.println("b is: "+b); if( h.lastIndexOf('+') > h.lastIndexOf('-')) { //System.out.println("test A"); h=h.replace(h.charAt(h.lastIndexOf('+')), '-'); b = h+b; return b; } else { //System.out.println("test B"); h=h.replace(h.charAt(h.lastIndexOf('-')), '+'); b = h+ b; return b; } } } else { b = "-" + b; return b; } } else { b = "-" + b; return b; } } String brackets(String b) { b = b.replace("(", ""); b = b.replace(")", ""); return b; } String check(String a) { String[] b=null; if(a.indexOf('+')==0) { a=a.substring(1); check(a); } if(a.contains("+")) { //System.out.println("This is inside minus"); /*if(a.indexOf('+') ==0) { a=a.substring(1); }*/ b = a.split("\\+",2); a=add(check1(b[0]),check(b[1])) ; return a; } else return check1(a); } private String check1(String a) { String[] b=null; if(a.contains("-")) { if(a.indexOf('-')==0) { a =a.substring(1); if(a.contains("-")) { b = a.split("-", 2); b[0] = "-" + b[0]; b[1] = "-" + b[1]; a = add(check2(b[0]), check1(b[1])); } else { //System.out.println("this is here"); a = "-"+a; a = check2(a); } } else { b = a.split("-", 2); //b[0] = "-" + b[0]; b[1] = "-" + b[1]; a = add(check2(b[0]), check1(b[1])); } return a; }else return check2(a); //throw new UnsupportedOperationException("Not yet implemented"); } private String check2(String a) { String[] b=null; if(a.contains("*")) { b = a.split("\\*",2); a = mult(check3(b[0]), check2(b[1])) ; return a; } else return check3(a); //throw new UnsupportedOperationException("Not yet implemented"); } private String check3(String a) { String[] b=null; if(a.contains("/")) { b = a.split("\\/"); a = divide(b[0], check3(b[1])) ; return a; } else return a; //throw new UnsupportedOperationException("Not yet implemented"); } } --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Thanks On Sun, Dec 30, 2007 at 11:10 PM, Pradyut Bhattacharya <pradyutb@gmail.com> wrote: Java code to evaluate in arithmetic expression...... -- Pradyut http://pradyut.tk http://www.pradyut.co.nr/ http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://groups.google.com/group/oop_programming India June 05 IT Companies Full Names...just don't miss it. :-)1. NIIT: Not Interested in IT 2. WIPRO: Weak Input, Poor & Rubbish Output 3. HCL: Hidden Costs & Losses 4. TCS : Totally Confusing Solutions 5. INFOSYS : Inferior Offline Systems 6. HUGHES : Highly Useless Graduates Hired for Eating and Sleeping 7. BAAN : Beggars Association and Nerds 8. IBM : Implicitly Boring Machines 9. SATYAM: Sad and Tired Yelling Away Madly 10. PARAM: Puzzled and Ridiculous Array of Microprocessors 11. C-DOT : Coffee during Office Timings 12. AT&T : All Troubles & Terrible 13. CMC : Coffee, Meals and Comfort 14. DEC : Drifting & Exhausted Computers 15. BFL : Brainwash first and Let them go 17. TISL : Totally Inconsistent Systems Ltd. 18. PSI : Peculiar Symptoms of India 19. ORACLE: On-line Romance And Chatting with Lady Employees . 20. PATNI : Pathetic Appraisal Techniques -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India motivation device-- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India Global peace rankings-- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India April 07 Re: simple css menuApril 06 Banta Sing Jokes !!!*********************************************** Prince Charles & Banta were having dinner. Prince said, "Pass the wine you divine". Banta thinks "how poetic" Babta says, "pass the custard you bastard". *********************************************** Banta at bar in New York . Man on his right says "Johny Walker single" Man on his left says "Peter Scotch single" Banta says - "Baljith Singh Married" *********************************************** Boss : am giving u job as a driver. STARTING salary Rs.2000/-, is it o.k Banta : U R great sir! Starting salary is o.k.......but?? how much is DRIVING salary...? *********************************************** Babta's theory : Moon is more impt. than Sun, coz it gives light at night when light is needed & Sun gives light during the day when light is not needed!!! *********************************************** Banta and Santa are driving a Car, one puts on the indicator and asks the other to check whether its working, he puts his head out and says YES...NO...YES...NO...YES...NO... *********************************************** Babta shouting 2 his girl friend " u said v will do register marriage and cheated me, I was waiting 4 u yesterday whole day in the post office.... *********************************************** Banta and Santa looking at Egyptian mummy. Banta : Look so many bandages, pakka lorry accident case. Santa : Aaho, lorry number is also written...BC 1760!!!.... *********************************************** Banta on an interview 4 da post detective. Interviewer : who killed Gandhi? Banta : Thank u sir 4 giving me d job, I will start investigating....... *********************************************** Banta for an exam had studied only one essay 'FRIEND', but in the exam the essay which came was 'FATHER' . he replaced friend with father in the essay and>it read: AM A VERY FATHERLY PERSON, I HAVE LOTS OF FATHERS, SOME OF MY FATHERS ARE MALE AND SOME ARE FEMALE. MY TRUE FATHER IS MY NEIGHBOUR. *********************************************** Interviewar: what s ur qualification? Banta : Sir I am Ph.d. Interviewar : what do u mean by Ph.d? Banta : (smiling) PASSED HIGHSCHOOL with DIFFICULTY.... *********************************************** Amitab in KBC: In which state Cauvery flows? Banta : liquid state..... Audience clapped.. Amitab stunned, looks behind, ALL WERE banta's relatives....... *********************************************** -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India March 24 mind games....If your eyes follow the movement of the rotating pink dot, you will only see one color, pink. If you stare at the black + in the center, the moving dot turns to green. Now, concentrate on the black + in the center of the picture. After a short period of time, all the pink dots will slowly disappear, and you will only see a green dot rotating... if you're lucky! It's amazing how our brain works. There really is no green dot, and the pink ones really don't disappear. This should be proof enough, we don't always see what we think we see. -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India March 20 forms authentication and session variablesForms authentication and session variables in asp.net navigate between default and webform3 for sessions navigate to webform2 for forms authentication Sources at: - http://myjavaserver.com/%7Epradyut/files/WebApplication2.zip -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India March 16 changing to absolute positioning in visual web 2008changing to absolute positioning visual web in visual studio 2008
Thanks -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India March 15 Re: simple css menuA better css menu... check it out... http://myjavaserver.com/%7Epradyut/files/test2.html Sources at: - http://myjavaserver.com/%7Epradyut/files/my menu.zip reply your comments.... Thanks... On Fri, Mar 14, 2008 at 1:23 AM, Pradyut Bhattacharya wrote: Extract the 3 files in the rar... -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India March 14 simple css menuExtract the 3 files in the rar... http://myjavaserver.com/%7Epradyut/files/my%20menu.rar the only difference between new2.html and new3.html is: - ------------------------------------------------------------------------------------------------------------------ <STYLE TYPE="text/css" MEDIA="screen, projection"> <!-- @import url(menu.css); DT { background: yellow; color: black } --> </STYLE> ------------------------------------------------------------------------------------------------------------------- wanna change the style.......... have fun with the css......... Thanks..... -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India March 12 Drawing Wild Animals on HandMarch 03 can someone...01. Call an old friend, just to say hi.
02. Hold a door open for a stranger. 03. Invite someone to lunch. 04. Compliment someone on his or her appearance. 05. Ask a coworker for their opinion on a project. 06. Bring cookies to work. 07. Let someone cut in during rush hour traffic. 08. Leave a waitress or waiter a big tip. 09. Tell a cashier to have a nice day. 10. Call your parents. 11. Let someone know you miss them.
12. Treat someone to a movie. 13. Let a person know you really appreciate them. 14. Visit a retirement center. 15. Take a child to the zoo. 16. Fill up your spouse's car with gas. 17. Surprise someone with a small gift. 18. Leave a thank-you note for the cleaning staff at work. 19. Write a letter to a distant relative. 20. Tell someone you thought about them the other day. 21. Put a dime in a stranger's parking meter before the time expires.
22. Bake a cake for a neighbor. 23. Send someone flowers to where they work. 24. Invite a friend to tea. 25. Recommend a good book to someone. 26. Donate clothing to a charity. 27. Offer an elderly person a ride to where they need to go. 28. Bag your own groceries at the checkout counter. 29. Give blood. 30. Offer free baby-sitting to a friend who's really busy or just needs a break. 31. Help your neighbor rake leaves or shovel snow.
32. Offer your seat to someone when there aren't any left. 33. Help someone with a heavy load. 34. Ask to see a store's manager and comment on the great service. 35. Give your place in line at the grocery store to someone who has only a few items. 36. Hug someone in your family for no reason. 37. Wave to a child in the car next to you. 38. Send a thank-you note to your doctor. 39. Repeat something nice you heard about someone else. 40. Leave a joke on someone's answering machine. 41. Be a mentor or coach to someone.
42. Forgive a loan. 43. Fill up the copier machine with paper after you're done using it. 44. Tell someone you believe in them. 45. Share your umbrella on a rainy day. 46. Welcome new neighbors with flowers or a plant. 47. Offer to watch a friend's home while they're away. 48. Ask someone if they need you to pick up anything while you're out shopping. 49. Ask a child to play a board game, and let them win. 50. Ask an elderly person to tell you about the good old days. 51. During bad weather, plan an indoor picnic with the family.
52. Buy someone a goldfish and bowl. 53. Compliment someone on their cooking and politely ask for a second helping. 54. Dance with someone who hasn't been asked. 55. Tell someone you mentioned them in your prayers. 56. Give children's clothes to another family when your kids outgrow them. 57. Deliver extra vegetables from your garden to the whole neighborhood. 58. Call your spouse just to say, I love you. 59. Call someone's attention to a rainbow or beautiful sunset. 60. Invite someone to go bowling. 61. Figure out someone's half-birthday by adding 182 days,
and surprise them with a cake. 62. Ask someone about their children. 63. Tell someone which quality you like most about them. 64. Brush the snow off of the car next to yours. 65. Return your shopping cart to the front of the store. 66. Encourage someone's dream, no matter how big or small it is. 67. Pay for a stranger's cup of coffee without them knowing it. 68. Leave a love letter where your partner will find it. 69. Ask an older person for their advice. 70. Offer to take care of someone's pet while they're away. 71. Tell a child you're proud of them.
72. Visit a sick person, or send them a care package. 73. Join a Big Brother or Sister program. 74. Leave a piece of candy on a coworker's desk. 75. Bring your child to work with you for the afternoon. 76. Give someone a recording of their favorite music. 77. Email a friend some information about a topic they are especially interested in. 78. Give someone a homemade gift. 79. Write a poem for someone. 80. Bake some cookies for your local fire or police department. 81. Organize a neighborhood cleanup and have a barbecue afterwards.
82. Help a child build a birdhouse or similar project. 83. Check in on an old person, just to see if they're okay. 84. Ask for the recipe after you eat over at someone's house. 85. Personally welcome a new employee at work and offer to take them out for lunch. 86. While in a car, ask everyone to buckle up because they are important to you. 87. Let someone else eat the last slice of cake or pizza. 88. Stop and buy a drink from a kid's lemonade stand. 89. Forgive someone when they apologize. 90. Wave to someone looking for a parking space when you're about to leave a shopping center. 91. Send a copy of an old photograph to a childhood friend.
92. Leave a pint of your spouse's favorite flavor of ice cream in the freezer with a bow on it. 93. Do a household chore that is usually done by someone else in the family. 94. Be especially happy for someone when they tell you their good news. 95. Compliment a coworker on their role in a successful project. 96. Give your spouse a spontaneous back rub at the end of the day. 97. Serve someone in your family breakfast in bed. 98. Ask someone if they've lost weight. 99. Make a donation to a charity in someone's honor. 100. Take a child to a ballgame. And last, but not least...
101. Forward this list to 10 of your favorite people!
-- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India February 16 A simple login application in J2MEA simple login application in j2me Source in: - http://www.myjavaserver.com/~pradyut/files/MobileApplication1%2016%20feb.zip Will open as netbeans project Mobile jar file:- http://www.myjavaserver.com/~pradyut/files/MobileApplication1.jar Thanks -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India December 30 java code to evaluate a arithmetic expression....Java code to evaluate in arithmetic expression...... following order... Division Multiplication Subtraction Addition The code: - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String a = "4-6-1+3*9/2"; //1*3+2*7-1-1 String[] b = null; String c = null; //double[] d =null; Main obj = new Main(); //double d1 = 0; System.out.println(obj.check(a)); /*b = obj.mul (a); //a = b[0].substring(0, b[1].length()-1) + func2(func3(b[0].trim()), b[1]).toString() + b[] System.out.println(b[0].substring(obj.last(b[0])+1, b[0].length())); System.out.println(b[1].substring(0, obj.first(b[1]))); c = obj.mult(b[0].substring(obj.last(b[0])+1, b[0].length()), b[1].substring(0, obj.first(b[1]))); System.out.println(d1); a = b[0].substring(0, obj.last(b[0])+1) +d1 + b[1].substring( obj.first(b[1]), b[1].length()); System.out.println("The string is: " + a); //System.out.print(func2(b[0].substring(0, func3(b[0].trim())), b[1].substring(func4(b[1].trim()), )); for(int i=0; i<b.length; i++) System.out.println(b[i]); //System.out.println(b[1].substring(0,b[1].indexOf('+'))); //String f = b[1].substring(0,b[1].indexOf('+')); //d1 = obj.func2(b[0], f); System.out.println("The addition: " + d1);*/ } double func(String a) { double d = 0; return d; } String mult(String a, String b) { double c = func1(a) * func1(b); return (Double.toString(c)); } String minus(String a, String b) { double c = func1(a) - func1(b); System.out.println(c); return (Double.toString(c)); } String add(String a, String b) { double c = func1(a) + func1(b); return (Double.toString(c)); } String divide(String a, String b) { double c = func1(a) / func1(b); return (Double.toString(c)); } double func1(String a) { double d =0; try { d = Double.parseDouble(a); } catch (NumberFormatException n1) { System.out.println(n1); } return d; } /*String[] mul(String a) { String[] b = null; b = a.split("\\*"); return b; } double mul1(String[] a) { double c = 0; try{ } catch() return c; }*/ /*int last(String a) { int c=0; char d; for(int i =a.length()-1; i>0; i=i-1) { if(a.charAt(i)=='+' || a.charAt(i)=='-' || a.charAt(i)=='*' || a.charAt(i)=='/') return i; } return c; } int first(String a) { int i=0; for(i =0; i<a.length(); ++i) { if(a.charAt(i)=='+' || a.charAt(i)=='-' || a.charAt(i)=='*' || a.charAt(i)=='/') return i; } return i; }*/ String check(String a) { String[] b=null; if(a.contains("+")) { //System.out.println("This is inside minus"); b = a.split("\\+",2); a=add(check1(b[0]),check(b[1])) ; return a; } else return check1(a); } private String check1(String a) { String[] b=null; //System.out.println(a); if(a.contains("-")) { //System.out.println("This is inside minus"); /*if(a.indexOf('-')!=0) { b = a.split("\\-",2); b[1] = "-" + b[1]; a = add(check2(b[0]), check1(b[1])) ; } else { a = add(check2(b[0]), b[1]) ; }*/ if(a.indexOf('-')==0) { a =a.substring(1); if( a.contains("-")) { b = a.split("-", 2); b[0] = "-" + b[0]; b[1] = "-" + b[1]; a = add(check2(b[0]), check1(b[1])); } else a = "-"+a; } else { b = a.split("-", 2); //b[0] = "-" + b[0]; b[1] = "-" + b[1]; a = add(check2(b[0]), check1(b[1])); } return a; }else return check2(a); //throw new UnsupportedOperationException("Not yet implemented"); } private String check2(String a) { String[] b=null; if(a.contains("*")) { b = a.split("\\*",2); a = mult(check3(b[0]), check2(b[1])) ; return a; } else return check3(a); //throw new UnsupportedOperationException("Not yet implemented"); } private String check3(String a) { String[] b=null; if(a.contains("/")) { b = a.split("\\/"); a = divide(b[0], check3(b[1])) ; return a; } else return a; //throw new UnsupportedOperationException("Not yet implemented"); } } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Reply any comments or suggestions....... Thanks.... -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India December 22 Kingfisher calendar pics....Kingfisher calendar pics.... http://myjavaserver.com/~pradyut/pics/slide/ -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ http://oop-edge.spaces.live.com/ http://www.flickr.com/photos/praddy http://groups.google.com/group/oop_programming India December 14 creating sql server JDBC poolThe blog at:- http://oop-edge.blogspot.com/2007/12/creating-sql-server-jdbc-pool.html Creating Sql Server 2005 JDBC connection pool in Glassfish v2 First we copy sqljdbc.jar file from the sql server jdbc driver distributed from Microsoft available here to the path \Program Files\glassfish-v2-b58g\lib. Then we open the admin console. The snapshot: - The main thing here: - The name should not contain underscore or other special characters or it may not work DataSource className: - com.microsoft.sqlserver.jdbc.SQLServerXADataSource Resource Type: - javax.sql.XADataSource In the Additional Properties the parameters should be correrct: - check out the sql server 2005 port number from Sql server Configuration Manager->Sql Server 2005 network configuration->Protocols for SqlExpress. If the TCP/IP is disabled, enable it. Right click on TCP/IP -> properties In the IP addresses tab, in IPAll see the parameter for TCP Dynamic Ports. same should be in the portNumber in Glassfish server Save the settings and test the connection by Ping button on the page. create a JDBC resource using the JDBC connection pool: - creating a connection to the JDBC resource (from a web page) using the code: - try { Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("test"); Connection c = ds.getConnection(); Statement st = c.createStatement(); ResultSet rs = st.executeQuery("...."); ............. ............... c.close(); } catch(NamingException e1) { label1.setText("Naming exception: " + e1); } catch (SQLException e2) { label1.setText("Sql exception: " + e2); } the imports should be: - import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; reply your comments.... thanks -- Pradyut http://pradyut.tk http://oop-edge.blogspot.com/ http://pradyutb.blogspot.com/ http://praddy-photos.blogspot.com/ | |||||||||||||||||||||||||||