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
Ads
Related Tutorials/Questions & Answers:
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
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
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
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
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
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
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... 'PHP
SQL close
Connection'. To
understand and grasp the example we include
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
sql php code
sql php
code
SQL PHP
code executes the statement using the mysql_query ( ) function... and
elaborate the example we have a PHP
server scripting
code that includes host,
user
JDBC-SERVLET
JDBC-SERVLET while doing
JDBC connectivity with
servlet my driver is getting load but its giving exception for
connection that DSN name not found...://www.devmanuals.com/tutorials/java/
servlet/ConnectDb.html
Thanks
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
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
JDBC-SERVLET
JDBC-SERVLET *while doing connectivity of
jdbc with
servlet I m....
***********My
code is********
<html>
<body>
<form action="
servlet...;
</html>
***************java
code***************
import java.io.
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
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
JDBC ODBC Connection In Java
is
sun.jdbc.odbc.JdbcOdbcDriver.
JDBC ODBC
Connection
To
Connect the
JDBC and ODBC...
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 Mysql Connection Url
JDBC Mysql
Connection Url
The Tutorial want to illustrate a
code that explain you to understand
JDBC Mysql
Connection. In this program, the
code explain the
JDBC url and string
JDBC connection
JDBC connection ![alt text][1]I got exception in Connecting to a MySQL Database in Java.
The exception is ClassNotFoundException:com.mysql.jdbc.Driver
wat is the problem
servlet code
servlet code how to implement insert update n delete in one
servlet in net beans
If you want to perform insert, update and delete functions in the same
servlet, then please visit the following links:
http
REQ for connection b/w jdbc and oracle database
REQ for
connection b/w
jdbc and oracle database REQ for
connection b/w
jdbc and oracle database
The Java classes to
connect... (OCI or Thin) through the
JDBC connection URL.
Here are some
connection URL
jdbc code
oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("
jdbc:oracle:thin...
jdbc code import java.sql.*;
import java.io.*;
import java.util.*;
public class CallBill
{
public static void main(String args[])throws
JDBC Connection and Registration
JDBC Connection and Registration
How to create a
JDBC connection... your java with
jdbc code.. It will create table in MS access database. Here..... :-)
JDBC MS Access Database Connectivity:
Follow these steps:
1)Go
not able to connect to mysql using.. jdbc
not able to
connect to mysql using..
jdbc i am not able to
connect to mysql using
jdbc ..
is there any classpath that i need to set..because i am using mysql-connector-java jar file..to
connect to mysql..
Pls provide the steps