JDBC Connection code to connect servlet with SQL Server 2008

JDBC Connection code to connect servlet with SQL Server 2008

Please ans me why it is not connect i use netbeans IDE7.0 Jdk 1.7 i also add sqljdbc4.jar but the output is SEVERE: Java Runtime Environment (JRE) version 1.6 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0. i try Avery thing but i m not success so please ans me .
My connection code is

static Connection con; static Statement st; static PreparedStatement ps; static final String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; static final String url = "jdbc:sqlserver://localhost=127.0.0.1:1433;databaseName=JSPPROJECT;selectMethod=cursor"; //localhost=127.0.0.1 //static String url ="jdbc.mssql:192.168.1.99:8080/Test"; static String userName ="sa"; static String password ="1309";

public MyDBConnection1() {
}


public static void getConnection(String InvoiceNo , String FirstName, String LastName, String CourseName, String BatchTime)
{
    try {
        try {
            Class.forName(driver);
        } 
        catch (ClassNotFoundException ex) 
        {
            ex.printStackTrace();
        }
        con = DriverManager.getConnection(url,userName,password);
        System.out.println("---connection establised ------"+con.toString());
        st=con.createStatement();
        String query = " insert into StudentDetails(InvoiceNo,FirstName,LastName,CourseName,BatchTime) values (InvoiceNo,FirstName,LastName,CourseName,BatchTime) ";
        //String query = " insert into StudentDetails(InvoiceNo,FirstName,LastName,CourseName,BatchTime) values (ivno,fname,lname,cname,btime) ";

        //ps = con.prepareStatement("insert into StudentInfo(studentId,studentName,studentAddress) values (?,?,?) ");
        //ps.setString(1, studentId);

        int record = st.executeUpdate(query);
        System.out.println(" Inserted Records :"+record);

    } 
    catch (SQLException ex) 
    {
        ex.printStackTrace();
    }
    finally 
    {
        try 
        {
            if(con!=null)
            {
                con.close();
            }
        }
        catch (SQLException ex) 
        {
            ex.printStackTrace();
        }
    }
}

public static void main(String args[])
{
    getConnection(driver, userName, userName, userName, userName);
}

}

View Answers

January 3, 2013 at 5:43 AM

remove sqljdbc.jar









Related Tutorials/Questions & Answers:
JDBC Connection code to connect servlet with SQL Server 2008
JDBC Connection code to connect servlet with SQL Server 2008  Please ans me why it is not connect i use netbeans IDE7.0 Jdk 1.7 i also add... connection code is static Connection con; static Statement st; static
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
Advertisements
Database connection sql server 2005 - JDBC
Database connection sql server 2005  Hi all i am developing an application in struts and i need to connect database for that application using sql server 2005.. can anyone tell me how to make database connection ..plz help me
SQL SERVER 2008
SQL SERVER 2008  when i am fill the all fields in the form.but when i am retrive from the database it shows only firstname,age,address.remaining fields was shows as null.and it shows the gender as the on.i can't understand what
Sql Server 2008 with textbox
Sql Server 2008 with textbox  **Hi, I tried to insert into DB using... for user 'sa'] i tried to get a solution for this error this the code i used... myconn = New SqlConnection("server=localhost;" & "Initial Catalog=4
could not connect to the server - JDBC
: Connection timed out: connect STACKTRACE: java.net.SocketException: java.net.ConnectException: Connection timed out: connect...could not connect to the server  Hii sir, I am working with a JBDC
JDBC connection and SQL Query - JDBC
JDBC connection and SQL Query  Hi, I'm reading a all files one after the other in a directory in java. storing the values in an array of string... to make it. even the code i wrote below has some error with quotation marks
Server DB connection - JDBC
Server DB connection  Hello Guys I want to connect two databases... get it to work. If you have any sample code for getting connection please.... One database is on my localhost and the other one is on server, I want
connect sql server 2005 using php
connect sql server 2005 using php  how to connect sql server 2005 using php program. how mssql_connect will work
how to connect SQL Server 2005 using php
how to connect SQL Server 2005 using php  i need to connect SQL Server 2005 using php. how can i connect . how to use mssql_connect function
Error while SQL Server connection to Java
Error while SQL Server connection to Java  import java.sql.*; public..."); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER;user=DTHOTA;password...("password", " "); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER", prop
Error while SQL Server connection to Java
Error while SQL Server connection to Java  import java.sql.*; public..."); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER;user=DTHOTA;password...("password", " "); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER", prop
server database connection - JSP-Servlet
server database connection  sir generally we will connect..."); 2.Connection con=DriverManager.getConnection("jdbc:odbc:Driver={Microsoft ODBC For Oracle}","scott","tiger"); But how to get the connection from
jdbc odbc sql server exception
jdbc odbc sql server exception  Hi, I am trying to use sql server with java jdbc odbc but I am getting this exception java.sql.SQLException: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '@P1
unable to connect to server - JSP-Servlet
unable to connect to server  thank you for the program code...-application-server/tomcat/install-configure.shtml Here you will get step by step installation and configuration of Apache Tomcat Server. After installation
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
Java servlet with jsp on sql server
Java servlet with jsp on sql server  How to delete a user by an admin with check box in Java Servlet with jsp on Sql Server?   Here... checkbox.In the given code, we have specified only three fields bookid,author
can't connect to MySQL Server(10060) - JDBC
can't connect to MySQL Server(10060)  Hii Sir, I am working with a jsp project with MySQL as server. Now i want to host my application. I am... MySQL front end. Can we connect to the MySQL server using the I.P address
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code:ADS_TO_REPLACE_1 1)form.html: <...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
JDBC connection
to understand JDBC connection. The code explains you   how... JDBC connection       The JDBC.... The JDBC includes execution of SQL queries return a result set over
Sql Connection is not creating
Sql Connection is not creating  Hi i am developing an web application..for that i am using excel as database. To connect for database am using jdbc... it is creating sql connection and allwoing me to access excel but when i am
how to connect mysql with JDBC - JDBC
in the database MYsql, i have to connect them now using JDBC, can u please suggest me... { connection = DriverManager.getConnection("jdbc:mysql://localhost...(); } } Thanks Rajanikant  Hi friend, To mysql connect using JDBC
HTML code to servlet to database using jdbc
HTML code to servlet to database using jdbc  pls send me the code related to the title   Hi Friend, Try the following code:ADS...); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
how can i create a mysql database to connect to this code - JDBC
"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register
how can i create a mysql database to connect to this code - JDBC
"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register
DataBase connection with sql - Struts
DataBase connection with sql  How to connect sql and send db error in struts? what are the tag should i code in struts-confic.xml
database connection - SQL
database connection  hi friends, This is poornima i want to connect sql server to my eclipse editer how to connect and where i have to write code...-database connection in eclipse IDE? Thanks
SQL connection error in android
SQL connection error in android  hi, i am android developer . recently i made one application connect with sql server 2005 using jtds...:sql:Exception : BUFFERDIR connection property invalid. if you have any answer
PHP SQL close connection
PHP SQL close connection       PHP SQL close connection is used to close a connection between the PHP... an example from 'PHP SQL close Connection'. To understand and grasp the example
JDBC Connection Pool
for JDBC connection pooling but instead of writing the code from scratch you...JDBC Connection Pool In this section we will learn about JDBC Connection Pool... application will give you improved performance if you use the JDBC Connection
java and sql server NOT Mysql - JSP-Servlet
java and sql server NOT Mysql  Hi guys. Thank you all... was not properly answered. What I wanted was JSP CODE that can insert and retrieve image from MS SQL server NOT MySQL. Or is it not possible to do it in MS SQL server
servlet - JDBC
connectivity. I want to change it "sql server 2005" connectivty because I don't know about oracle.I am giving this code below please connect this code from sql server 2005.where my "server name=MANEESH-PC", authentication="sql server
sql php code
sql php code       SQL PHP code executes the statement using the mysql_query ( ) function...'. To understand and elaborate the example we have a PHP server scripting code
connection - JDBC
connection  how to connect server pages to mysql  Hi Friend, To learn how to connect MySql to JSP, please visit the following link: http://www.roseindia.net/jsp/connect-jsp-mysql.shtml Thanks
Java Jdbc connection
Java Jdbc connection  What are the steps involved for making a connection with a database or how do you connect to a database
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been successful so far. However when i try to connect to sql through a normal java program
Java Connect to and FTP Server
Java Connect to and FTP Server  What is the code for Java Connect to and FTP Server? How to establish a connection to FTP server in Java? Thansk... the apache commons library to connect/login to FTP server. Link of complete example
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect...) { System.out.println("MySQL Connect Example."); Connection conn = null
JDBC connection timeout
The code include a class JDBC Connection Timeout, inside the main method we include... JDBC connection timeout       The Tutorial describe you a JDBC Connection timeout. In this program, we
i can not connect to database in servlet - JSP-Servlet
offer .   Hi friend, Code to connect to database in servlet... the tutorial in this site on servlet and JDBC. I did all the proccedure for connecting...(""); out.println("Servlet JDBC"); out.println(""); out.println("Servlet JDBC
i can not connect to database in servlet - JSP-Servlet
offer .   Hi friend, Code to connect to database in servlet... the tutorial in this site on servlet and JDBC. I did all the proccedure for connecting..."); PrintWriter out = response.getWriter(); out.println(""); out.println("Servlet JDBC
jdbc connection issues
in the database correspondingly. How pls tell me how connect these 11 forms and 11 tables with only one jdbc connection program...if possiable pls post a sample code...jdbc connection issues  Hello. kindly pls help in this issue...i
connect with Database - SQL
connect with Database  Hi, when ever i m trying to connect with 10g ..i m getting error .. Failed to get a connection org.jboss.util.NestedSQLException: Could not create connection; - nested throwable
code - JSP-Servlet
want to execute some sql query.so i write one javascript function. but i dont know how can i call database connection in javascript. please help me   use some server side script like servlet or jsp, call these when user click
connect jdbc to an Excel spreadsheet
connect jdbc to an Excel spreadsheet  hello, How can I connect to an Excel spreadsheet file using jdbc?   Hello Friend,ADS_TO_REPLACE_1...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc
jdbc connection
"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1...jdbc connection  How to Submit data????   <%-- view... { Class.forName("com.mysql.jdbc.Driver"); Connection con = (Connection
servlet-jdbc
. 5)Your DSN will get created. 6) Compile your servlet and restart the server and run your servlet. Here is your required servlet code: import java.io.... = "jdbc:odbc:student"; Connection connection; try{ String username
connection - SQL
connection  how can i establish connection between netbean_ide6.9 with mysql or oracle  Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/visual-jsf.shtml Hope that it will be helpful
JDBC ODBC Connection In Java
is sun.jdbc.odbc.JdbcOdbcDriver.ADS_TO_REPLACE_1 JDBC ODBC Connection To Connect...JDBC ODBC Connection In Java In this section we will read about the various aspects of JDBC ODBC such as, JDBC-ODBC bridge, JDBC ODBC connection, how
JDBC connection pooling
JDBC connection pooling  What is Connection pooling

Ads