Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Getting "Jdbc is not defined" when running code on Visual Studio Code

Octopus

New Coder
Hello to all,
I am in the process of building a simple and small app using javascript and a remote MySql database, so i set up this project in Visual Studio Code:
project.jpg

The following code works perfectly when I run it under Google Appscript:
JavaScript:
var port = 3306;
var dbName = "sql7621994";
var username = "sql7621994";
var password = "xxxxxxxxxx";
var server = "sql7.freemysqlhosting.net";

function xsomareg() {
  try {
    var url = 'jdbc:mysql://' + server + ':' + port + '/' + dbName;
    var conn = Jdbc.getConnection(url, username, password);
    var stmt = conn.createStatement();
    var guarda = stmt.executeQuery("SELECT SUM(valor) FROM registos");
    guarda.next();
    console.log(guarda.getDouble(1));
  } catch (err) {
    console.log('Failed with error: %s', err.message);
  }
}
THE PROBLEM: When I use it under Visual Studio Code (in the apps.js file) I get the message "Jdbc is not defined", as follows:
error.jpg
Using SqlTools extension, I am able to run the SELECT statement is VSC and get the correct result:
select.jpg


I am very new to this and probably making some mistake. So I will be grateful if someone please can give a hand on this.
Octavio
:
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom