Share on Google+Share on Google+

Trushna
JDBC Connection code to connect servlet with SQL Server 2008
1 Answer(s)      4 years and 8 months ago
Posted in : JSP-Servlet

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);
}

}

Ads

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
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
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
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
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
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
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
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
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
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
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
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: 1)form.html: <html> <...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc
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
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
JDBC connection
to understand JDBC connection. The code explains you   how... Jdbc Connection, We have a list of method required to connect and close... JDBC connection       The JDBC
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
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
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
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
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
PHP SQL close connection
PHP SQL close connection       PHP SQL close connection is used to close a connection between the PHP... 'PHP SQL close Connection'. To understand and grasp the example we include
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads