Saturday 29 December 2012

How to connect to MySql using JSP


How to connect to MySql using JSP

<%@ page import = "java.sql.*"%>
<html>
<head>
<title>Obtaining a Connection </title>
</head>
<body>
<%
Connection conn=null;
ResultSet result=null;
Statement stmt=null;
ResultSetMetaData rsmd=null;
try
{
Class c=Class.forName("com.mysql.jdbc.Driver");
}
catch(Exception e)
{
out.write("Error!!!!!!" + e);
}
try
{
conn=DriverManager.getConnection("jdbc:mysql://192.168.110.5:3306/databasename","username","password");
out.write("Connected!");
}
catch(SQLException e)
{
System.out.println("Error!!!!!!" + e);
}


1) Change 192.168.110 from the above script to your url for e.g. localhost
2) databasename, username and password to your databasename, username and password

Note: Please make sure you already download the mysql-connector for Java
http://dev.mysql.com/downloads/connector/j/

I preferred using Netbeans as IDE for JSP.


Saturday 6 October 2012

wamp installation the program can't start because msvcr100.dll is missing from your computer

On Windows 7(64 bit - 32bit) every time when i try to install i have the same problem. on the end of installations its shows this messages: 
The application has failed to start because msvcr100.dll was not found. re-insalling the application may fix the problem. 
After that i click ok and installation is over.


Solution 
-----------

1) Close down all the programs
2) Uninstall Wamp
3) Make sure Internet Explorer is set your default browser before the installation.
4) download Microsoft Visual C++ 2010 SP1 Redistributable Package (x86) and install ...

here's link to the VC++ redistributable 

[www.microsoft.com]
5) Make sure no other programs are using port 80 (Such as IIS, Skype..etc)
6) Reboot the machine
7) Run the Wamp as an administrator
8) It might ask you to select Explorer.exe, all you need to click Open button as by default it opens the location c:\windows

Once you follow the above, hopefully the issue will be no longer apparent.

Any problems feel free to leave your comments or feedback.

Thanks for reading