Help .. am new to db in hava
hi there
i have this code i guess its a database connection to MYSQL ...
i need to change it to SQL SERVER 2000 .....
so how it differs .....?????and i need some comments to understand what its all about ?
please this is urgent ....???
* Servlet for DB connection*/
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class getConnection extends HttpServlet
public void init()
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
BufferedReader in = request.getReader();
String db = in.readLine();
String user = in.readLine();
String pwd = in.readLine();
/*String db = "test";
String user = "root";
String pwd = "caspian";*/
String message ="jdbc:mysql://localhost:3306/"+
db+","+user+","+pwd;
try
connect(db.toLowerCase().trim(),user.toLowerCase().trim(),
pwd.toLowerCase().trim());
message += "100 ok";
catch (Throwable t)
message += "200 " + t.toString();
response.setContentType("text/plain");
response.setContentLength(message.length());
PrintWriter out = response.getWriter();
out.println(message);
out.println(db);
out.println(user);
out.println(pwd);
out.flush();
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
doPost(request,response);
/* This method connects to MYSQL database*/
private void connect(String db, String user,
String pwd) throws Exception
// Establish a JDBC connection
// to the MYSQL database server.
//Class.forName("org.gjt.mm.mysql.Driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/"+db,user,pwd);
// Establish a JDBC connection to the Oracle database server.
//DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
//Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:"+db,user,pwd);
// Establish a JDBC connection to the SQL database server.
//Class.forName("net.sourceforge.jtds.jdbc.Driver");
//Connection conn = DriverManager.getConnection(
// jdbc:jtds:sqlserver://localhost:1433/+db,user,pwd);
}
I've added comments and fixed the formatting (and use the [ code ] tags to make it more readable).
However, you can figure 90% of this out from reading the java.sql API:
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/package-summary.html
and the rest you can get by Googling for tutorials and documentation, such as this one:
http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
You might also look at the basics of httpservlet, e.g.:
http://www.jayeckles.com/tutorials/servlets.pc
/* Servlet for DB connection*/
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class getConnection extends HttpServlet
// HttpServlet - init() method should only present if it's being overridden
//public void init()
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
// this isn't how you normally get request information from an http request
// BufferedReader in = request.getReader();
// get the parameters from the web form by name
// replace the quoted values with whatever the fields actual names are
// and clean up the data ASAP
String db = request.getParameter("db").toLowerCase().trim();
String user = request.getParameter("user").toLowerCase().trim();
String pwd = request.getParameter("pwd").toLowerCase().trim();
/*String db = "test";
String user = "root";
String pwd = "caspian";*/
String message ="jdbc:mysql://localhost:3306/"+db+","+user+","+pwd;
try
connect(db,user,pwd);
message += "100 ok";
// you normally shouldn't catch Error throwables, only the Exception throwables
// Error throwables are non-recoverable errors and it's usually a bad thing to catch them
catch (Exception e)
message += "200 " + e.toString();
response.setContentType("text/plain");
// it's not required to set a ContentLength, but it you do set it, DO NOT set it wrong
// if set, it should be the length of everything set to the "out" PrintWriter,
// including line end characters
// response.setContentLength(message.length());
PrintWriter out = response.getWriter();
out.println(message);
out.println(db);
out.println(user);
out.println(pwd);
// this is unneeded, flush is automatic when the servlet ends
// it can't hurt and in some scenarios it's helpful
// out.flush();
// treate GET requests the same as posts
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
doPost(request,response);
/* This method connects to MYSQL database*/
private void connect(String db, String user, String pwd) throws Exception
// Establish a JDBC connection
// to the MYSQL database server.
//Class.forName("org.gjt.mm.mysql.Driver");
// load the MySQL driver class
// every database has a different one
Class.forName("com.mysql.jdbc.Driver").newInstance();
// ask the driver manager for a connection for this database URL
// this assumes that the database is running on your machine and
// is using the standard MySQL port
// the DriverManager figures out which driver is needed by asking each loaded driver
// if it knows how to handle the database URL, the first paramter of the method
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+db,user,pwd);
// Establish a JDBC connection to the Oracle database server.
//DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
//Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:"+db,user,pwd);
// Establish a JDBC connection to the SQL database server using the jtds driver.
//Class.forName("net.sourceforge.jtds.jdbc.Driver");
//Connection conn = DriverManager.getConnection(
// jdbc:jtds:sqlserver://localhost:1433/+db,user,pwd);
}
Similar Messages
-
I had to purchase a new laptop, since my old one crased. I downloaded iTunes, and my library came up. I followed the directions given, synced ipod, authorized computer and was given a pop up that stated 25 of my songs could not be transferred.Go to Store, authorize computer and resync. Which I did. When I authorize computer another pop up appears and it states this computer is already authorized. I am getting really frustrated. I have gone to the Apple store several times, had to make appointments as they were to busy to help me then. I show up for appointments to either be told, no appointment appears in their schedule, or they are running over an hour late. Any help would be greatly appreciated! Thanks
Why can't the songs be transferred to the device? Is it because they are not authorized? Were these 25 tracks purchased/downloaded with the same account you have used to authorize the PC/new iTunes library?
Have you seen this article yet?
iTunes repeatedly prompts to authorize computer to play iTunes Store purchases
B-rock -
I want to transfer a movie I have bought in itunes to my new IPAD. I have been trying to work how to do this for 3 days now. I have accessed all the itunes help and forums and wiki online. They all tell me to go to the DEVICES tab on itunes and select IPAD then sync. YUP seem simple, BUT there is not DEVICES tab listed on my itunes and it does not list IPAD. Years ago I set up my IPOD no problem and that is listed, but not the new IPAD. Can anyone help? I would love to be able to actually watch films on my IPAD!! thanks
If you have iTunes 11 on your computer then you can enable the left-hand sidebar on it via option-command-S on a Mac, control-S on a PC - when connected (and if your computer's iTunes is up-to-date) your iPad should then appear on that sidebar under a 'Devices' heading :
If you select the iPad on that sidebar you can then use the Movies tab on the right-hand side of the iTunes screen to select and sync that film to your iPad's Videos app.
Has your iPad been synced to the computer before ? If not then you might find this page for syncing to a new computer useful : https://discussions.apple.com/docs/DOC-3141 -
Hi everyone,
I am looking for help and maybe someone can help me please. My hard drive crashed and dell installed a new one. I have two iphones and an ipad with all my apps, music, amd photos. Can anyone indicate me what to do so I do not lose everything when I plug in my phone. ThanksNaturally you should have a recent backup of your "crashed" hard drive. If you don't, well, hopefully you've learned a lesson but that doesn't solve your current problem.
If all your apps and media were purchased from the iTunes App Store, don't worry about them. Redownload all your apps and media, then allow iTunes to sync with and wipe your iOS devices - which will also put all the apps and media on them. You'll lose your settings, and any data which resided only on the iOS devices, and of course you'll need to organize your iOS folders and home screens and whatnot. But you won't really lose much, and without a backup this is your best choice.
If you have media from sources other than the iTunes App Store, look at Senuti or similar applications designed to copy media from iOS devices to computers. Use that first, then sync as I described in my second paragraph above. (I mention Senuti because it's popular. There are other options which work just as well, and some are even free.) -
I have just getting a new phone and I have forgot my password an Apple ID what I made new for the new phone now I cannot get on it because asking for id and password what should I do help plz thank u
Try
https://iforgot.apple.com -
Question: I am new to LR and have it set up on a Mac desktop and laptop. On the laptop, the Basic function under Develop simply disappeared. I am lost. Help.
It's a common issue. The Basic panel is merely hidden.
Hiding/unhiding panels is actually a feature of Lightroom but it is unintuitive - few people know it exists - so most newcomers are thrown when a panel somehow gets hidden.
Right-click anywhere in the right hand side panel area and a context menu will appear.
Click the Basic option to make the Basic panel re-appear. -
When I enter my password to start my atv it tells me, that "there was a problem connecting to the network." My Ipad works fine in my house, but not my new atv. I have reset my password multiple times with no help. I have also rebooted my wireless server. Do I take it back?
Where is everyone???? Does anyone have an answer???
Allik1 -
I have an wireless Apple Keyboard and Mouse from my G5 Pro Mac, 2006. I would like to use it on a newer Intel xeon with blue tooth. Initally I was able to set them up.. Today Is another story. I have delete them as devices and have had no luck setting them up.. Help.. Many Thanks folks I am sure one of you good souls can help me out.. I have loaded the updates and am running 10.6.8. Are there issues using early apple wireless keyboards and a mouse.
I have an wireless Apple Keyboard and Mouse from my G5 Pro Mac, 2006. I would like to use it on a newer Intel xeon with blue tooth. Initally I was able to set them up.. Today Is another story. I have delete them as devices and have had no luck setting them up.. Help.. Many Thanks folks I am sure one of you good souls can help me out.. I have loaded the updates and am running 10.6.8. Are there issues using early apple wireless keyboards and a mouse.
-
When trying to update getting (error surle error domain error-1100). It started yesterday, any help would be great. I have Mountain Lion 10.8.1 on a new macbook pro with retina display.
There are many people suffering from this problem right now (including me). It appears to be a server issue. Just wait and try checking for updates again tomorrow.
Some things I have heard indicate that this may be a regional problem, though what parts of the world are affected I don't know yet. A few people have been helped by deleting the following preference file (paste the path into the Go -> Go to Folder window in the Finder to locate it), though most have not:
~/Library/Preferences/com.apple.SoftwareUpdate.plist
Note that if you are trying to download iTunes 10.7, that can be found here:
http://support.apple.com/kb/DL1576
Also, note that there is no reason to be anxious to get it, as the only thing added in iTunes 10.7 is compatibility with iOS 6, which will not be available until the 19th, and the new iPhone, which will not be available until later as well. The new iTunes that was announced is iTunes 11, which is also not yet available. -
My iPhone4s has been stolen,and it has been repaired in somewhere!Once the stealer had a new iPhone,I couldnot have my iPhone forever!what should I do?I am inChina,I have call police.But police seem to see it small.please help me,it has been my second lost iPhone4s
There is nothing to do. You have done all you can.
Buy a new iphone.
Buy a different phone.
Do without a phone. -
Can anyone help me? I just want to know if I just put my iPhone 4 which has been fixed can I start it as a new phone and still have my contacts and photos as it won't let me log in with my iCloud address
Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.
-
I didn't have this problem before with Firefox. My kids must have pressed something or clicked on something that's the open new tab button does not function anymore. No matter how you click it, it doesn't open a new tab. Even if you click on file, then go to new tab, it still doesn't open a new tab. You have to open a new firefox window in order to do multiple browsing.
Hope you can help resolve this problem.
Sincerely,
Ems GuillarteUninstall the Ask toolbar and it should work again. There is a compatibility issue with the Ask toolbar and Firefox that prevents new tabs from being opened. Checking your list of add-ons, the MyPlayCity toolbar is a version of the Ask toolbar.
There are a couple of places to check for the Ask toolbar:
* Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
* Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons -
I have tried downloading photoshop cs2 and cs4 on a new computer. I have the disc available for cs2 and the serial number for cs4. They are both registered in my name. I need help doing a download. I was able to get part way through cs4, it showed up in my downloads but never got as far in the process as to ask for serial numbers. I tried with cs2 and I got an error message that some bit of information was incorrect. I currently have both downloaded on two other lap tops I own. One is operational and one is dead. I cannot access the dead one to remove the program. Thank you in advance for any assistance.
For CS2 you will need to download a special new version
CS2 Activation
You might find CS4 download here
Prodesign Tools — Photoshop Direct Download Links -
Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.
Adobe - Lightroom : For Macintosh
Hal -
I got my Imac and Trackpad in may so its new and the batterys have run out on the trackpad, so i have put new batterys in and its not even turning back on i have tried the batterys the other way round ( i used duracell) and still not working, so i put the old batterys in and it still wont turn on. I am getting so angry woth apple things, the make it sound better than it is and over pice it, i paid over a grand for my imac and it dont even come with a cd SLOT. Please can some one help!
Edge has very clear restrictions, one being that you must have 6 months of clean payment history which you don't. Either wait until April 14, or good luck at Sprint.
I am unsure how it can be determined the payment mix up was the fault of CS, but regardless, the mix up was done. There can be any number of reasons why a payment could be missed without any fault on your part, however you are still the responsible party for the account and must live with the repercussions. -
i buy new iphone but i have problem in my mobile. it's need activation and i dont no how to active its need sim activation but i take it from UK and my brother send me this phone in saudi arabia i am old coustomer of apple so please help me i am suck
If the phone is locked to a carrier then you will need the carrier to unlock it And only the carrier can do that.
Maybe you are looking for
-
How do you download Kindle book to iPhone 5s?
I have many Kindle books I've purchased from Amazon; they are accessible to me on-line and I can download them at will to my Kindle. But how can I download them to my Iphone 5s?
-
'Undo' no longer working in Outlook inbox after a message delete
I've been using Outlook 2010 for a couple of years; I used to occasionally use 'Undo' (or ctrl-Z) to bring back a message I had just deleted from Inbox after reading it. It was a limited undo - I could only bring back the one message - but it did get
-
Hi folks, I need faqs on ABAP HR (with answers). Could any body send me some material to attend interview on ABAP HR.Please i want with ansers as i amvery new to ABAP HR. Thanks, Shyam.
-
What kind of timeouts present in SAP Portal?
Hi there, i have a Question. In the portal there are Session Timeouts. Thats OK. But now i want to know what kind of other timeouts are in the portal. Can you help here? Thanks Bjoern
-
Error during installing Asphalt Elite racing
Iam using nokia N86 8MP. I have downloaded and installed Asphalt Elite racing game. I accidentally uninstalled it. When Iam trying to download and install it again, it is showing that the application could not be completed due to an error. Can anyone