I am coding a module in java that need a database connection with MySQL. I heard about DriverManager but I think it is pretty old method for database connection. Is there any newer and efficient way of doing the same. This]Java questions and answers forum comprises of large number of tech and coding expert, So I expect quick and satisfactory solution or full set of instruction/ code require for this.
I call fake post. Besides, this is a not a Java forum.
This]Java questions and answers forum comprises of large number of tech and coding expert, So I expect quick and satisfactory solution or full set of instruction/ code require for this.LOL! LMAOF, ROFL, SMH, WTF!
As a ‘tech lead’ in java, how do you not know how to connect to a database?
Since you did not explain why you would want to make a Javascript connection to a online database,
I agree this might be a fake post. JS is not secure for accessing an online database!
Are you writing a desktop app? Since JS on a server really runs in the browser, there is no security for your
code. If you are doing a server app, then, switch to PHP. Either way, here is how you can connect to an
online database in JS…
[php]
var connection = new ActiveXObject(“ADODB.Connection”) ;
var connectionstring=“Data Source=;Initial Catalog=;User ID=;Password=;Provider=SQLOLEDB”;
connection.Open(connectionstring);
var rs = new ActiveXObject(“ADODB.Recordset”);
rs.Open(“SELECT * FROM table”, connection);
rs.MoveFirst
while(!rs.eof)
{
document.write(rs.fields(1));
rs.movenext;
}
rs.close;
connection.close;
[/php]
It’s very similar to ASP… Fill in the provider code and user/pass, etc… Not sure if this helps…
He said Java, not JavaScript. While he may be switching them, I don’t think in this case he is. I would say this is for JSP or J2EE.
Oh, yeah! I hate that… Names are too similar! LOL
Well, if Java, it now has it’s own database connection code built-in, doesn’t it? DriveManager!
https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html
Yes you are Right… I was talking about Java (J2EE) Language… not JavaScript
This would be the first thing I would do:
https://docs.oracle.com/javase/tutorial/jdbc/basics/sqldatasources.html